Hadoop-1.0.1 中的 java.lang.NoClassDefFoundError
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10637861/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.lang.NoClassDefFoundError in Hadoop-1.0.1
提问by Ravi Joshi
i am working with Hadoop-1.0.1 in Eclipse. I am trying to run wordcountapplication but when i run my WordCount.java, Eclipse shows me following error
我正在 Eclipse 中使用 Hadoop-1.0.1。我正在尝试运行wordcount应用程序,但是当我运行 WordCount.java 时,Eclipse 显示以下错误
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.hadoop.conf.Configuration.<clinit>(Configuration.java:143)
at test.WordCount.main(WordCount.java:56)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
... 2 more
I have hadoop-core-1.0.1.jar in my classpath
. Should the application require more jar
我的 .jar 文件中有 hadoop-core-1.0.1.jar classpath
。应用程序是否需要更多 jar
回答by AvkashChauhan
It seems you are getting this error because either two important logging classes commons-logging-1.1.1.jar and commons-logging-api-1.0.4.jar which are related with common logging is either not available from your classpath or you just don't have it.
您似乎收到此错误,因为与公共日志记录相关的两个重要日志记录类 commons-logging-1.1.1.jar 和 commons-logging-api-1.0.4.jar 要么从您的类路径中不可用,要么您只是没有它。
In most cases these files are in \lib folder with other Hadoop Jar so when you set class path these jar are accessible. Please verify that you do have these files in your machine and are set in your classpath so they are accessible.
在大多数情况下,这些文件与其他 Hadoop Jar 位于 \lib 文件夹中,因此当您设置类路径时,这些 jar 是可访问的。请确认您的机器中确实有这些文件,并且在您的类路径中设置了它们以便可以访问。
Also when you run "hadoop version" the version comes up as result, the same hadoop-core--SNAPSHOT.jar must be in your $HADOOP_HOME location.
同样,当您运行“hadoop version”时,版本也会出现,相同的 hadoop-core--SNAPSHOT.jar 必须位于您的 $HADOOP_HOME 位置。
You mentioned that you are running WordCount.javainstead you should say that you are running WordCount job because you are always using the compiled application as jar not java.
你提到你正在运行WordCount.java而你应该说你正在运行 WordCount 作业,因为你总是使用编译的应用程序作为 jar 而不是 java。
$ bin/hadoop jar /usr/jboss/wordcount.jar org.myhadoop.WordCount /usr/jboss/wordcount/input /usr/jboss/wordcount/output
$ bin/hadoop jar /usr/jboss/wordcount.jar org.myhadoop.WordCount /usr/jboss/wordcount/input /usr/jboss/wordcount/output
回答by jana91
It seems that you did not include the common-logging jar file so Download Herethe jar file depends on version, Then will included it in your program and run it THANK yoU
您似乎没有包含 common-logging jar 文件,因此请在此处下载jar 文件取决于版本,然后将其包含在您的程序中并运行它,谢谢
回答by Jean Logeart
hadoop-core-1.0.1
is probably not in your classpath: commons-logging
is actually included several times in the hadoop jar!
hadoop-core-1.0.1
可能不在您的类路径中:commons-logging
实际上已多次包含在 hadoop jar 中!