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.
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
Related
I have compiled and made an executable jar file for db2triples program. I am using the following command for executing the jar file.
java -cp target/dependency/*.jar:target/db2triples-1.0.3-SNAPSHOT.jar net.antidot.semantic.rdf.rdb2rdf.main.Db2triples
The main class has not been defined in the MANIFEST.MF file, therefore, I am explicitly defining it in the command.
The net.antidot.semantic.rdf.rdb2rdf.main.Db2triples is the location of the main class in the target/classes directory.
I am using Windows operating system.
Update:
After using semicolon the following error crops up:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2693)
at java.lang.Class.privateGetMethodRecursive(Class.java:3040)
at java.lang.Class.getMethod0(Class.java:3010)
at java.lang.Class.getMethod(Class.java:1776)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.cli.ParseException
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
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)
... 7 more
You need to either run the command from the target/classes directory or add the target/classes directory to your -cp list.
I am trying to use Xstream in android studio. Below is the entry in
build.gradle:
compile('com.thoughtworks.xstream:xstream:1.4.7') {
exclude module: 'xmlpull'
}
When I run my code I get the below exception:
"C:\Program Files\Java\jdk1.7.0_79\bin\java" -Didea.launcher.port=7532 "-Didea.launcher.bin.path=C:\Program Files\Android\Android Studio\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\pandes4\AppData\Local\Android\sdk\platforms\android-23\android.jar;C:\Users\pandes4\AppData\Local\Android\sdk\platforms\android-23\data\res;C:\Users\pandes4\Desktop\project\TransactionSigningSDK\app\build\intermediates\classes\debug;C:\Users\pandes4\Desktop\project\TransactionSigningSDK\app\build\intermediates\exploded-aar\com.android.support\recyclerview-v7\23.1.0\res;C:\Users\pandes4\Desktop\project\TransactionSigningSDK\app\build\intermediates\exploded-aar\com.android.support\recyclerview-v7\23.1.0\jars\classes.jar;C:\Users\pandes4\AppData\Local\Android\sdk\extras\android\m2repository\com\android\support\support-annotations\23.1.0\support-annotations-23.1.0.jar;C:\Users\pandes4\.gradle\caches\modules-2\files-2.1\com.google.code.ksoap2-android\ksoap2-android\3.0.0\3ea828ba22ed4ecb84052e90caf1522fcef44384\ksoap2-android-3.0.0.jar;C:\Users\pandes4\Desktop\project\TransactionSigningSDK\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\jars\classes.jar;C:\Users\pandes4\Desktop\project\TransactionSigningSDK\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\res;C:\Users\pandes4\.gradle\caches\modules-2\files-2.1\net.sourceforge.kxml\kxml\2.2.4\1642506e490548d96984b8370e44257c156097f7\kxml-2.2.4.jar;C:\Users\pandes4\.gradle\caches\modules-2\files-2.1\com.google.code.ksoap2-android\ksoap2-base\3.0.0\a5ae46b8c2407144aa6afa89cba7c3e37df273e2\ksoap2-base-3.0.0.jar;C:\Users\pandes4\.gradle\caches\modules-2\files-2.1\com.thoughtworks.xstream\xstream\1.4.7\bce3282142b63068260f021fcbe48b72e8d71a1a\xstream-1.4.7.jar;C:\Users\pandes4\Desktop\project\TransactionSigningSDK\app\build\intermediates\exploded-aar\com.android.support\design\23.1.0\res;C:\Users\pandes4\Desktop\project\TransactionSigningSDK\app\build\intermediates\exploded-aar\com.android.support\design\23.1.0\jars\classes.jar;C:\Users\pandes4\.gradle\caches\modules-2\files-2.1\net.sourceforge.kobjects\kobjects-j2me\0.0-SNAPSHOT-20040926-2\9246ca92b16c65114a7fb80b906801e06be95305\kobjects-j2me-0.0-SNAPSHOT-20040926-2.jar;C:\Users\pandes4\Desktop\project\TransactionSigningSDK\app\build\intermediates\exploded-aar\com.android.support\support-v4\23.1.0\res;C:\Users\pandes4\Desktop\project\TransactionSigningSDK\app\build\intermediates\exploded-aar\com.android.support\support-v4\23.1.0\jars\classes.jar;C:\Users\pandes4\Desktop\project\TransactionSigningSDK\app\build\intermediates\exploded-aar\com.android.support\support-v4\23.1.0\jars\libs\internal_impl-23.1.0.jar;C:\Users\pandes4\.gradle\caches\modules-2\files-2.1\com.google.code.ksoap2-android\ksoap2-j2se\3.0.0\ffd2d3fe6de12c5405abecadd1f4e740daf74742\ksoap2-j2se-3.0.0.jar;C:\Users\pandes4\.gradle\caches\modules-2\files-2.1\xpp3\xpp3_min\1.1.4c\19d4e90b43059058f6e056f794f0ea4030d60b86\xpp3_min-1.1.4c.jar;C:\Program Files\Android\Android Studio\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain com.rsa.mobile.android.transactionsigningsdk.transaction.TransactionPayloadProcessorImpl
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/jettison/mapped/Configuration
at com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver.<init>(JettisonMappedXmlDriver.java:55)
at
com.rsa.mobile.android.transactionsigningsdk.transaction.TransactionPayloadProcessorImpl.processTransactionPayload(TransactionPayloadProcessorImpl.java:16)
at com.rsa.mobile.android.transactionsigningsdk.transaction.TransactionPayloadProcessorImpl.main(TransactionPayloadProcessorImpl.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.lang.ClassNotFoundException: org.codehaus.jettison.mapped.Configuration
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)
... 8 more
Process finished with exit code 1
Am I supposed to add codehaus jettison libraries seperately?
When I tried adding jettison to the build.gradle I get
java returned 1
exception.
I'm trying to run a simple unit test to my project at https://github.com/cdwijayarathna/oj4j.
I added both junit-4.12.jar and ant-junit4.jar to the lib folder.
But when I ran "rake run_tests", I'm getting following error at the report location I have given.
java.lang.NoClassDefFoundError: junit/framework/JUnit4TestAdapterCache
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
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)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:195)
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)
What's the reason for that? how can I solve this?
I had the same exception running junit through ant on Debian. By including the junit4.jar in the $CLASSPATH environment variable I was able to get it running. Which means the jvm was not picking up on the junit4.jar. The /usr/share/java/junit4.jar path is specific to Debian's junit package, so you will need to replace as appropriate.
$ export CLASSPATH=/usr/share/java/junit4.jar
$ ant test
I use specific jars to run tests on a project, here is the command line which solve this issue:
$ CLASSPATH=lib/hamcrest-core-1.3.jar:lib/junit-4.12.jar ant my-junit-target
I've wrote a small shell to encapsulate this command.
Set ANT_HOME your $CLASSPATH environment variables.
When i run command ./runExamples.sh on terminal it throws an exception. I have checked that Java is installed and class path is already set. How to resolve this?
Starting examples app with java from environment variable PATH...
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.optaplanner.examples.common.app.CommonApp.<clinit>(CommonApp.java:36)
at org.optaplanner.examples.app.OptaPlannerExamplesApp.main(OptaPlannerExamplesApp.java:72)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
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)
... 2 more
You miss the slf4j.jar in your classpath. download and add it.
i am geting following error
Am i missing some jar file?
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.slf4j.impl.JCLLoggerFactory.getLogger(JCLLoggerFactory.java:69)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:243)
at org.smslib.helper.Logger.<init>(Logger.java:34)
at org.smslib.Service.<init>(Service.java:93)
at SendMessage.doIt(SendMessage.java:28)
at SendMessage.main(SendMessage.java:82)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 6 more
Java Result: 1
Yes, you need the Apache Logging JAR file on your classpath. Download it here: http://commons.apache.org/downloads/download_logging.cgi
Adding the jar files to ant lib will make them available for ant's java process and not your applications java process. Setting your application's classpath correctly must work.