1

I have created an map-red job which uses the apache-commons-cli library shipped with the hadoop under $HADOOP_HOME/lib/.

Now, if I create a jar and then try to run my job using

./hadoop -jar myjob.jar

I get the below exception:

Warning: $HADOOP_HOME is deprecated.

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/cli/CommandLineParser
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2521)
at java.lang.Class.getMethod0(Class.java:2764)
at java.lang.Class.getMethod(Class.java:1653)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.cli.CommandLineParser
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:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357

I can see that common-cli-xxx.jar is present in my $HADOOP_HOME/lib dir. I don't know what wrong I am doing here.

halfer
  • 19,824
  • 17
  • 99
  • 186
ASingh
  • 475
  • 1
  • 13
  • 24

1 Answers1

1

Type just hadoop in your terminal if it does not show list of all the hadoop command, you can check whether

export PATH=$PATH:$HADOOP_HOME/bin
export HADOOP_HOME=/usr/local/hadoop

lines are added to your .bashrc

  • It shows me the list of hadoop command. Still facing the same issue. Any other guesses...? – ASingh Oct 12 '13 at 04:22
  • check this it might help it will suppress the warning regarding the error we need to see.http://stackoverflow.com/questions/9286983/hadoop-home-is-deprecated – sameer_mishra Oct 13 '13 at 15:35
  • you need to add Apache Commons CLI jar in your classpath.your program is not able to find the CommandLineParser – sameer_mishra Oct 13 '13 at 15:39
  • export myjob.jar with all hadoop lib in its classpath and then try executing the jar – K S Nidhin Oct 17 '13 at 08:57