1. 程式人生 > >Hadoop 運行jar包時 java.lang.ClassNotFoundException: Class com.zhen.mr.RunJob$HotMapper not found

Hadoop 運行jar包時 java.lang.ClassNotFoundException: Class com.zhen.mr.RunJob$HotMapper not found

yar error not caused not found mapred info group col

錯誤如下

Error: java.lang.RuntimeException: java.lang.ClassNotFoundException: Class com.zhen.mr.RunJob$HotMapper not found
    at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:2154)
    at org.apache.hadoop.mapreduce.task.JobContextImpl.getMapperClass(JobContextImpl.java:186)
    at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:
742) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341) at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:163) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:422) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:
1692) at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158) Caused by: java.lang.ClassNotFoundException: Class com.zhen.mr.RunJob$HotMapper not found at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:2060) at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:
2152) ... 8 more

錯誤出現之前還有警告提示,如下

 WARN mapreduce.JobResourceUploader: No job jar file set.  User classes may not be found. See Job or Job#setJar(String).

提示說沒有設置job jar

解決方法:

代碼中給job對象set一下

job.setJarByClass(RunJob.class);

然後再打包運行就ok了。

Hadoop 運行jar包時 java.lang.ClassNotFoundException: Class com.zhen.mr.RunJob$HotMapper not found