Hadoop java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils

时间:2023-12-30 16:13:50

commons-lang3-3.3..jar 学习好友推荐案例的时候,提交运行时报错找不到StringUtils

java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
[root@node01 ~]# hadoop jar MyFOF.jar com.sxt.hadoop.mr.fof.MyFOF
// :: WARN mapreduce.JobResourceUploader: Hadoop command-line option parsing not performed. Implement the Tool interface and execute your application with ToolRunner to remedy this.
// :: INFO input.FileInputFormat: Total input paths to process :
// :: INFO mapreduce.JobSubmitter: number of splits:
// :: INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1553914110426_0006
// :: INFO impl.YarnClientImpl: Submitted application application_1553914110426_0006
// :: INFO mapreduce.Job: The url to track the job: http://node03:8088/proxy/application_1553914110426_0006/
// :: INFO mapreduce.Job: Running job: job_1553914110426_0006
// :: INFO mapreduce.Job: Job job_1553914110426_0006 running in uber mode : false
// :: INFO mapreduce.Job: map % reduce %
// :: INFO mapreduce.Job: Task Id : attempt_1553914110426_0006_m_000000_0, Status : FAILED
Error: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
at java.net.URLClassLoader.findClass(URLClassLoader.java:)
at java.lang.ClassLoader.loadClass(ClassLoader.java:)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:)
at java.lang.ClassLoader.loadClass(ClassLoader.java:)
at com.sxt.hadoop.mr.fof.FMapper.map(FMapper.java:)
at com.sxt.hadoop.mr.fof.FMapper.map(FMapper.java:)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:)
at org.apache.hadoop.mapred.YarnChild$.run(YarnChild.java:)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:)
at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:) // :: INFO mapreduce.Job: Task Id : attempt_1553914110426_0006_m_000000_1, Status : FAILED
Error: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
at java.net.URLClassLoader.findClass(URLClassLoader.java:)
at java.lang.ClassLoader.loadClass(ClassLoader.java:)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:)
at java.lang.ClassLoader.loadClass(ClassLoader.java:)
at com.sxt.hadoop.mr.fof.FMapper.map(FMapper.java:)
at com.sxt.hadoop.mr.fof.FMapper.map(FMapper.java:)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:)
at org.apache.hadoop.mapred.YarnChild$.run(YarnChild.java:)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:)
at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:) // :: INFO mapreduce.Job: Task Id : attempt_1553914110426_0006_m_000000_2, Status : FAILED
Error: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
at java.net.URLClassLoader.findClass(URLClassLoader.java:)
at java.lang.ClassLoader.loadClass(ClassLoader.java:)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:)
at java.lang.ClassLoader.loadClass(ClassLoader.java:)
at com.sxt.hadoop.mr.fof.FMapper.map(FMapper.java:)
at com.sxt.hadoop.mr.fof.FMapper.map(FMapper.java:)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:)
at org.apache.hadoop.mapred.YarnChild$.run(YarnChild.java:)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:)
at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:) Container killed by the ApplicationMaster.
Container killed on request. Exit code is
Container exited with a non-zero exit code // :: INFO mapreduce.Job: map % reduce %
// :: INFO mapreduce.Job: Job job_1553914110426_0006 failed with state FAILED due to: Task failed task_1553914110426_0006_m_000000
Job failed as tasks failed. failedMaps: failedReduces: // :: INFO mapreduce.Job: Counters:
Job Counters
Failed map tasks=
Killed reduce tasks=
Launched map tasks=
Other local map tasks=
Data-local map tasks=
Total time spent by all maps in occupied slots (ms)=
Total time spent by all reduces in occupied slots (ms)=
Total time spent by all map tasks (ms)=
Total time spent by all reduce tasks (ms)=
Total vcore-milliseconds taken by all map tasks=
Total vcore-milliseconds taken by all reduce tasks=
Total megabyte-milliseconds taken by all map tasks=
Total megabyte-milliseconds taken by all reduce tasks=
Map-Reduce Framework
CPU time spent (ms)=
Physical memory (bytes) snapshot=
Virtual memory (bytes) snapshot=

编译时没问题,提交运行错误,说明在运行环境中找不到StringUtils。

解决办法:

从/opt/sxt/hadoop-2.7.7/share/hadoop/tools/lib目录下拷贝commons-lang3-3.3..jar到opt/sxt/hadoop-2.7.7/share/hadoop/common/lib目录下,然后将commons-lang3-3.3..jar分别拷贝到各DataNode[root@node01 lib]# scp commons-lang3-3.3..jar node02:`pwd`

commons-lang3-3.3..jar                                                                    %  403KB   .1MB/s   :
[root@node01 lib]# scp commons-lang3-3.3..jar node03:`pwd`
commons-lang3-3.3..jar                                       100%  403KB   7.6MB/s   00:00

[root@node01 lib]# scp commons-lang3-3.3..jar node04:`pwd`
commons-lang3-3.3..jar                       100%  403KB   7.0MB/s   00:00