您的位置:首页 > 移动开发

hadoop客户端提交作业错误:java.lang.RuntimeException: java.lang.ClassNotFoundException: Job$Mappe

2014-11-10 18:49 471 查看
Eclipse远程调用hadoop出错:java.lang.RuntimeException: java.lang.ClassNotFoundException: Job$Mappe

转自:
http://my.oschina.net/mkh/blog/340112 http://www.cnblogs.com/chenying99/archive/2013/06/02/3113474.html http://www.linuxidc.com/Linux/2012-02/54711.htm (http://techme.lofter.com/post/ccd6e_1e772b)

eclipse直接提交mapreduce任务所需环境配置代码如下所示:

添加类EJob

修改后的wordcount代码如下(转自别人的,我没测过)

?
或者这样调用(本人测试过)
public static void main(String[] args) throws Exception {

// Add these statements. XXX

File jarFile = EJob.createTempJar("bin");

EJob.addClasspath("/usr/hadoop-1.2.1/conf");//好像不加这句也可以,没有什么用

ClassLoader classLoader = EJob.getClassLoader();

Thread.currentThread().setContextClassLoader(classLoader);

Configuration conf = new Configuration();

conf.set("mapred.job.tracker", "Master.Hadoop:54311");

String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();

if (otherArgs.length != 2) {

System.err.println("Usage: wordcount <in> <out>");

System.exit(2);

}

Job job = new Job(conf, "word count");

((JobConf)job.getConfiguration()).setJar(jarFile.toString());

job.setJarByClass(WordCount.class);

job.setMapperClass(TokenizerMapper.class);

job.setCombinerClass(IntSumReducer.class);

job.setReducerClass(IntSumReducer.class);

job.setOutputKeyClass(Text.class);

job.setOutputValueClass(IntWritable.class);

FileInputFormat.addInputPath(job, new Path(otherArgs[0]));

FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));

System.exit(job.waitForCompletion(true) ? 0 : 1);

}

不加 conf.set("mapred.job.tracker", "Master.Hadoop:54311");会出错

 参考文献:https://issues.apache.org/jira/browse/HADOOP-8089

   错误信息如下:

    ERROR security.UserGroupInformation: PriviledgedActionException as: hadoop cause:java.io.IOException Failed to set permissions of path:\usr\hadoop\tmp\mapred\staging\hadoop753422487\.staging
to 0700 Exception in thread "main" java.io.IOException: Failed to set permissions of path: \usr\hadoop\tmp \mapred\staging\hadoop753422487\.staging to
0700

   解决方法:

Configuration conf = new Configuration();

conf.set("mapred.job.tracker", "[server]:9001");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐