简体   繁体   English

运行jar时出现HADOOP_CLASSPATH问题

[英]HADOOP_CLASSPATH issue while running jar

I have created an map-red job which uses the apache-commons-cli library shipped with the hadoop under $HADOOP_HOME/lib/. 我创建了一个地图红色作业,该作业使用hadoop在$ HADOOP_HOME / lib /下提供的apache-commons-cli库。

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. 我可以看到$ HADOOP_HOME / lib目录中存在common-cli-xxx.jar。 I don't know what wrong I am doing here. 我不知道我在这里做什么错。

Type just hadoop in your terminal if it does not show list of all the hadoop command, you can check whether 如果您的终端没有显示所有hadoop命令的列表,请在终端中输入just hadoop,您可以检查是否

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

lines are added to your .bashrc 行添加到您的.bashrc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM