1
votes

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?

4

4 Answers

1
votes

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.

0
votes

You should add commons-logging-1.1.1.jar to your eclipse project and rebuild again.

0
votes

Please add all .jar in /usr/local/hadoop/share/hadoop/common/lib

0
votes

Check whether you have added jars from usr/lib/hadoop-0.20-mapreduce/bin

Add all the jars in this: Add all the jars in this

This solved my problem when I am running a MapReduce program directly from eclipse.