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

Posted 144823836yj

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Hadoop java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils相关的知识,希望对你有一定的参考价值。

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

java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
[[email protected] ~]# hadoop jar MyFOF.jar com.sxt.hadoop.mr.fof.MyFOF
19/03/30 00:25:37 WARN mapreduce.JobResourceUploader: Hadoop command-line option parsing not performed. Implement the Tool interface and execute your application with ToolRunner to remedy this.
19/03/30 00:25:37 INFO input.FileInputFormat: Total input paths to process : 1
19/03/30 00:25:38 INFO mapreduce.JobSubmitter: number of splits:1
19/03/30 00:25:38 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1553914110426_0006
19/03/30 00:25:38 INFO impl.YarnClientImpl: Submitted application application_1553914110426_0006
19/03/30 00:25:38 INFO mapreduce.Job: The url to track the job: http://node03:8088/proxy/application_1553914110426_0006/
19/03/30 00:25:38 INFO mapreduce.Job: Running job: job_1553914110426_0006
19/03/30 00:25:51 INFO mapreduce.Job: Job job_1553914110426_0006 running in uber mode : false
19/03/30 00:25:51 INFO mapreduce.Job:  map 0% reduce 0%
19/03/30 00:26:01 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:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at com.sxt.hadoop.mr.fof.FMapper.map(FMapper.java:20)
    at com.sxt.hadoop.mr.fof.FMapper.map(FMapper.java:1)
    at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:146)
    at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:787)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
    at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
    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:1762)
    at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)

19/03/30 00:26:14 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:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at com.sxt.hadoop.mr.fof.FMapper.map(FMapper.java:20)
    at com.sxt.hadoop.mr.fof.FMapper.map(FMapper.java:1)
    at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:146)
    at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:787)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
    at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
    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:1762)
    at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)

19/03/30 00:26:24 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:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at com.sxt.hadoop.mr.fof.FMapper.map(FMapper.java:20)
    at com.sxt.hadoop.mr.fof.FMapper.map(FMapper.java:1)
    at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:146)
    at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:787)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
    at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
    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:1762)
    at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)

Container killed by the ApplicationMaster.
Container killed on request. Exit code is 143
Container exited with a non-zero exit code 143

19/03/30 00:26:35 INFO mapreduce.Job:  map 100% reduce 100%
19/03/30 00:26:35 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:1 failedReduces:0

19/03/30 00:26:35 INFO mapreduce.Job: Counters: 16
    Job Counters 
        Failed map tasks=4
        Killed reduce tasks=1
        Launched map tasks=4
        Other local map tasks=3
        Data-local map tasks=1
        Total time spent by all maps in occupied slots (ms)=36188
        Total time spent by all reduces in occupied slots (ms)=0
        Total time spent by all map tasks (ms)=36188
        Total time spent by all reduce tasks (ms)=0
        Total vcore-milliseconds taken by all map tasks=36188
        Total vcore-milliseconds taken by all reduce tasks=0
        Total megabyte-milliseconds taken by all map tasks=37056512
        Total megabyte-milliseconds taken by all reduce tasks=0
    Map-Reduce Framework
        CPU time spent (ms)=0
        Physical memory (bytes) snapshot=0
        Virtual memory (bytes) snapshot=0

 

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

解决办法:

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

commons-lang3-3.3.2.jar                                                                    100%  403KB   8.1MB/s   00:00
[[email protected] lib]# scp commons-lang3-3.3.2.jar node03:`pwd`
commons-lang3-3.3.2.jar                                          100%  403KB   7.6MB/s   00:00
[[email protected] lib]# scp commons-lang3-3.3.2.jar node04:`pwd` commons-lang3-3.3.2.jar                       100%  403KB   7.0MB/s   00:00 

以上是关于Hadoop java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils的主要内容,如果未能解决你的问题,请参考以下文章

ClassNotFoundException - com.mysql.jdbc.Driver / 导入 mysql-connector-java 后

从 PySpark 3.1.2 连接 Oracle DB - Py4JJavaError 失败

hadoop2.删除对hadoop3.有影响吗

Hadoop开发 Hadoop视频教程 段海涛老师Hadoop完全攻克Hadoop视频教程 Hadoop开发

hadoop 配置文件放到哪里

hadoop2 环境的搭建(自动HA)