I am getting a NoClassDefFound error when trying to run Spark. I cannot figure out the reason behind this. Please help.
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/spark/sql/SchemaRDD
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:659)
at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:180)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:205)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:120)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: java.lang.ClassNotFoundException: org.apache.spark.sql.SchemaRDD
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 10 more
NoClassDefFoundError means Java couldn't find the Class it was looking for. That normally means:
You defined wrongly the classpath.
Java is finding and using the wrong version of the jar (probably because of Maven dependency hell).
Solution for 1 is to check the classpath: make sure you are including the jar that defines org.apache.spark.sql.SchemaRDD.
Solution for 2 is to check if you have a Maven dependency that depends (transitively) on an older version of the resource that defines that class.
Related
Error log:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/text/StrSubstitutor
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.text.StrSubstitutor
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 7 more
I know that people have asked this question before but none of them are using the Dropwizard framework.
Here is what I have tried:
Different versions of Dropwizard using the pom.xml,
Adding commons-lang and commons-text don't seem to fix it, though commons-text makes it throw a different error,
Restarting my computer.
It is a pretty involved pom.xml file which I am not comfortable sharing...
Any ideas why this is happening?
Is it possible, that you compile with a newer version (like Java 8) and run it with an older version (Java 7)? If yes, check the Path. (1)
Another thing could be, that the apache libraries are compiled with a more recent version.
(1) Try comparing the output of java --version and javac --version
In my program I have several modules placed in different folders and all of them are dependent on a "core" module.
I have already setup a configuration for Intellij to run the program, but every time I try to run I receive a ClassNotFound Excpetion. I'm not sure if this is due to my core module having a similar packages i.e. com.adpetlabs.flappybird
Could the problem be related to the packages or something else? I really need help in resolving this
Stacktrace:
Exception in thread "main" java.lang.ClassNotFoundException: com.adeptlabs.flappybird.desktop.DesktopLauncher
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)
I am having trouble while trying to run the example for printer.
when i try to run the class for the server it prints
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: Ice/LocalException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: Ice.LocalException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
For what i have been searching it is caused by the classpath export?
i did export CLASSPATH=$CLASSPATH:./classes:$ICE_HOME/share/java/ice.jar
ICE_HOME is /usr.
Does anyone know how to fix? thanks
After typing the question continued looking for it. As it seems exports are wierd, when i do ctrl + shift + T for a new terminal it deletes them. Only after looking at the exports page i realized they were getting deleted.
for those who've managed to use this java implementation of leveldb https://github.com/dain/leveldb/
I'm getting the following stacktrace when I try to execute the code in the readme:
NoClassDefFoundError occurs when runing the following line:
DB db = factory.open(new File("example"), options);
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Lists
at org.iq80.leveldb.impl.DbImpl.(DbImpl.java:95)
at org.iq80.leveldb.impl.Iq80DBFactory.open(Iq80DBFactory.java:59)
at com.test.LevelDBDain.main(LevelDBDain.java:23)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Lists
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)
I confirmed that new File("example") returns a non-null value; same as the variable options
I import two jars built from the source into my library:
1.leveldb-api.jar
2.leveldb.jar
I've tried this with releases 0.6, 0.7 and 0.8-SNAPSHOT and always get the same error.
Could it be something I'm doing wrong ...or missing?
com.google.common.collect.util from guava is a dependency of the leveldb library but for some reason adding it explicitly as a dependency for my java project solved the problem.
I am trying to extract noun phrases from text using the illinois chunker however i seem to be getting something wrong. I am trying to run the command in a centos6.4 system with jdk1.8 having downloaded the jar given in the link.
java -Xmx512m -classpath /path/to/LBJChunk.jar edu.illinois.cs.cogcomp.lbj.chunk.ChunksAndPOSTags snippeting.txt
this returns a class not found exception, what am i doing wrong >:( do i have to download an other jar for the parser?
Exception in thread "main" java.lang.NoClassDefFoundError: LBJ2/parse/Parser
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2688)
at java.lang.Class.getMethod0(Class.java:2937)
at java.lang.Class.getMethod(Class.java:1771)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: LBJ2.parse.Parser
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)
... 6 more
You'll need some more jars on the classpath. It's not very clear, but the description for the chunker notes that LBJ (a language library) and the Illinois POS tagger are required. You can get more information on how to run it here.
Then, run this command:
java -classpath /path/to/LBJChunk.jar:/path/to/LBJ2Library.jar:/path/toLBJPOS.jar \
edu.illinois.cs.cogcomp.lbj.chunk.ChunksAndPOSTags snippeting.txt
That should work!