无法在hadoop java.lang.NoClassDefFoundError中使用第三方jar

时间:2013-10-24 17:56:18

标签: java hadoop

我正在尝试加入两个数据集..其中一个是json .. 我依靠json-simple库来解析那个json .. 我正在尝试使用libjars ..到目前为止..对于简单的数据处理..方法已经有效..但现在我收到以下错误

Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:820)
    at org.apache.hadoop.mapreduce.lib.input.MultipleInputs.getMapperTypeMap(MultipleInputs.java:141)
    at org.apache.hadoop.mapreduce.lib.input.DelegatingInputFormat.getSplits(DelegatingInputFormat.java:60)
    at org.apache.hadoop.mapred.JobClient.writeNewSplits(JobClient.java:1024)
    at org.apache.hadoop.mapred.JobClient.writeSplits(JobClient.java:1041)
    at org.apache.hadoop.mapred.JobClient.access$700(JobClient.java:179)
    at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:959)
    at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:912)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:415)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1136)
    at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:912)
    at org.apache.hadoop.mapreduce.Job.submit(Job.java:500)
    at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:530)
    at org.select.Driver.run(Driver.java:130)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
    at org.select.Driver.main(Driver.java:139)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
Caused by: java.lang.ClassNotFoundException: org.json.simple.parser.ParseException
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)

我想我已经实现了toolrunner。

hadoop jar domain_gold.jar org.select.Driver \
-libjars json-simple-1.1.1.jar  $INPUT1 $INPUT2 $OUTPUT

代码 http://pastebin.com/7XnyVnkv

1 个答案:

答案 0 :(得分:0)

将您的第三方JAR文件放在hadoop的默认lib文件夹之一上。例如,$ HADOOP_HOME / share / hadoop / common / lib。