I am trying to run a Hadoop wordcount job (I am using hadoop 2.6.0). When I export my project to runnable jar and run it from CLI it works. However when I launch it in Eclipse with "Run as java application" I receive the following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.apache.hadoop.conf.Configuration.(Configuration.java:173) at WordCount.main(WordCount.java:54) Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory 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:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 2 more
Can anybody assist me with this issue?
I think you have not properly configured Eclipse and it doesn't know where to find the Apache Commons libraries jars. From this tutorial , you may be missing the last steps:
To run tests from Eclipse you need to additionally do the following:
- Under project Properties, select Java Build Path, and the Libraries tab
- Click "Add External Class Folder" and select the build directory of the current project
You may also want to take a look at this other tutorial where it shows how/where to add the dependencies jars to run a Hadoop program.
您应该将commons-logging-1.1.1.jar添加到您的Eclipse项目中,然后重新构建 。
请在/usr/local/hadoop/share/hadoop/common/lib
添加所有.jar
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.