mapred.JobClient: No job jar file set. User classes may not be found. See JobConf(Class) or JobConf#setJar(String).

时间:2022-06-07 09:15:02

报错详情:

WARN mapred.JobClient: No job jar file set.  User classes may not be found. See JobConf(Class) or JobConf#setJar(String).
10/08/16 15:25:49 INFO input.FileInputFormat: Total input paths to process : 4
10/08/16 15:25:50 INFO mapred.JobClient: Running job: job_201008161439_0004
10/08/16 15:25:51 INFO mapred.JobClient:  map 0% reduce 0%
10/08/16 15:26:00 INFO mapred.JobClient: Task Id : attempt_201008161439_0004_m_000000_0, Status : FAILED

java.lang.RuntimeException: java.lang.ClassNotFoundException: org.apache.hadoop.examples.WordCount2$WordCountMapper at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:808) at org.apache.hadoop.mapreduce.JobContext.getMapperClass(JobContext.java:157) at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:532) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:305) at org.apache.hadoop.mapred.Child.main(Child.java:170) Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.examples.WordCount2$WordCountMapper at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

 报错原因:

找不到job任务运行的资源,如map类、reduce类等。

 解决方案:

新增
public class InitMain{
    Job job = new Job();  
    job.setJarByClass(InitMain.class); //只要是Initmain类所在包下的任一个类名都可以,默认为当前 job所在类名。
}

 扩展:

Hadoop之——MapReduce job的几种运行模式

运行一个Hadoop Job所需要指定的属性

MapReduce 中job.setJarByClass()方法的疑惑

Hadoop Job的提交