运行时显示mapper类未找到异常

时间:2015-02-03 12:42:34

标签: hadoop mapreduce hbase

地图0%减少0% 15/02/03 07:30:28 INFO mapreduce.Job:任务ID:attempt_1422885720829_0097_m_000000_0,状态:未通过 错误:java.lang.RuntimeException:java.lang.ClassNotFoundException:未找到类org.cognizant.pr2.TroubleMapper         在org.apache.hadoop.conf.Configuration.getClass(Configuration.java:1720)         at org.apache.hadoop.mapreduce.task.JobContextImpl.getMapperClass(JobContextImpl.java:186)         在org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:721)         在org.apache.hadoop.mapred.MapTask.run(MapTask.java:339)         在org.apache.hadoop.mapred.YarnChild $ 2.run(YarnChild.java:162)         at java.security.AccessController.doPrivileged(Native Method)         在javax.security.auth.Subject.doAs(Subject.java:396)         at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1491)         在org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:157) 引起:java.lang.ClassNotFoundException:未找到类org.cognizant.pr2.TroubleMapper         在org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:1626)         在org.apache.hadoop.conf.Configuration.getClass(Configuration.java:1718)         ......还有8个

15/02/03 07:30:32 INFO mapreduce.Job:任务ID:attempt_1422885720829_0097_m_000000_1,状态:未通过 错误:java.lang.RuntimeException:java.lang.ClassNotFoundException:未找到类org.cognizant.pr2.TroubleMapper         在org.apache.hadoop.conf.Configuration.getClass(Configuration.java:1720)         at org.apache.hadoop.mapreduce.task.JobContextImpl.getMapperClass(JobContextImpl.java:186)         在org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:721)         在org.apache.hadoop.mapred.MapTask.run(MapTask.java:339)         在org.apache.hadoop.mapred.YarnChild $ 2.run(YarnChild.java:162)         at java.security.AccessController.doPrivileged(Native Method)         在javax.security.auth.Subject.doAs(Subject.java:396)         at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1491)         在org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:157) 引起:java.lang.ClassNotFoundException:未找到类org.cognizant.pr2.TroubleMapper         在org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:1626)         在org.apache.hadoop.conf.Configuration.getClass(Configuration.java:1718)         ......还有8个

15/02/03 07:30:35 INFO mapreduce.Job:任务ID:attempt_1422885720829_0097_m_000000_2,状态:未通过 错误:java.lang.RuntimeException:java.lang.ClassNotFoundException:未找到类org.cognizant.pr2.TroubleMapper         在org.apache.hadoop.conf.Configuration.getClass(Configuration.java:1720)         at org.apache.hadoop.mapreduce.task.JobContextImpl.getMapperClass(JobContextImpl.java:186)         在org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:721)         在org.apache.hadoop.mapred.MapTask.run(MapTask.java:339)         在org.apache.hadoop.mapred.YarnChild $ 2.run(YarnChild.java:162)         at java.security.AccessController.doPrivileged(Native Method)         在javax.security.auth.Subject.doAs(Subject.java:396)         at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1491)         在org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:157) 引起:java.lang.ClassNotFoundException:未找到类org.cognizant.pr2.TroubleMapper         在org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:1626)         在org.apache.hadoop.conf.Configuration.getClass(Configuration.java:1718)         ......还有8个

15/02/03 07:30:39 INFO mapreduce.Job:地图100%减少100% 15/02/03 07:30:39 INFO mapreduce.Job:作业job_1422885720829_0097因状态失败而失败,原因是:任务失败task_1422885720829_0097_m_000000 任务失败,作业失败。 failedMaps:1次失败减少:0

15/02/03 07:30:39 INFO mapreduce.Job:专柜:6         工作柜台                 失败的地图任务= 4                 启动地图任务= 4                 其他本地地图任务= 3                 数据本地映射任务= 1                 占用时隙中所有映射所花费的总时间(ms)= 8357                 所有花费的总时间减少了占用的时隙(ms)= 0

3 个答案:

答案 0 :(得分:1)

重新编译您的Java代码,并确保您拥有所有可用于运行mr作业的jar。

"su - hdfs" 

export HADOOP_CLASSPATH=`hbase classpath`

#### export HADOOP_CLASSPATH=/etc/hbase/conf:/usr/lib/hbase/*:jar

并运行MR代码!

答案 1 :(得分:1)

我得到了这个问题的解决方案,就像我们可以将jar直接放在这个路径下:/ usr / lib / hadoop-mapreduce目录并从这个路径本身运行cmd。现在它将能够访问所需的一个。我希望它会有所帮助。谢谢大家:-)

答案 2 :(得分:0)

我使用下面的驱动程序类代码来解决此问题。

public int run(String[] args) throws Exception {

    Configuration conf=new Configuration();
    Job job=Job.getInstance(conf, "MavenSample");

    ***job.setJarByClass(DriverClass.class);***

    job.setMapperClass(MapperClass.class);
    job.setReducerClass(ReducerClass.class);

    job.setMapOutputKeyClass(Text.class);
    job.setMapOutputValueClass(IntWritable.class);

    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(IntWritable.class);

    FileInputFormat.setInputPaths(job, new Path(args[0]));
    FileOutputFormat.setOutputPath(job, new Path(args[1]));         

    return job.waitForCompletion(true)?0:1;

}