NoClassDefFoundError resolved by renaming the JAR file - java

I have a large java application running on a Red Hat Enterprise Linux server. This application has around 100 jars. On most RHEL systems the application runs fine, however, on certain RHEL systems (all RHEL versions are the same) I get a NoClassDefFoundError on startup (before my application gets a chance to do anything). If I rename the JAR file which contains the class (e.g. com-test-1.3.4.jar -> com-test-1.3.4-2.jar) everything starts up great even though the renameing doesn't change the order of the JAR in my directory listing. If I add the JAR file to the beginning of the classpath it works great. On other systems with the exact same OS/classpath/java/jars it works great. If I try to run the class that java says is missing (before renaming), java reports that the class does not have a main method so I know the class itself is loadable/findable. I have tried the latest version of Java 1.7 with no luck. The classpath is specified using the wildcard operator (e.g. CLASSPATH=/home/test/*).
The actual exception:
Exception in thread "main" java.lang.NoClassDefFoundError: com/test/testpath/TestClass
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
at java.lang.Class.getMethod0(Class.java:2774)
at java.lang.Class.getMethod(Class.java:1663)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: com.test.testpath.TestClass
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)
... 6 more

Related

GATE Java error

I know almost nothing about Java so please take it easy on me. I'm using this plugin, which I've had working nicely for a few days on my Mac (following the repo's very simple instructions below), but when I took it to an Ubuntu instance I got the following error:
ResumeParser/ResumeTransducer$ java -cp 'bin/*:../GATEFiles/lib/*:../GATEFILES/bin/gate.jar:lib/*' code4goal.antony.resumeparser.ResumeParserProgram somefile.pdf somefile.json
Exception in thread "main" java.lang.NoClassDefFoundError: gate/SimpleAnnotation
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2625)
at java.lang.Class.getMethod0(Class.java:2866)
at java.lang.Class.getMethod(Class.java:1676)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: gate.SimpleAnnotation
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)
... 6 more
Anyone have thoughts on what is going wrong?
Installation and usage instructions:
1. git clone https://github.com/antonydeepak/ResumeParser.git
2. cd ResumeParser/ResumeTransducer
3. export GATE_HOME="..\GATEFiles"
Paths are case sensitive in Ubuntu, GATEFiles is different from GATEFILES. Since gate.SimpleAnnotation is in gate.jar, I bet that your classpath should be:
-cp 'bin/:../GATEFiles/lib/:../GATEFiles/bin/gate.jar:lib/*'
Disclaimer: I haven't used this plugin, I don't know if the other parts of the classpath are correct.
In general, you can "debug" by trying
ls ../GATEFiles/bin/
to see if there is a gate.jar file.
It's hard to know, but most likely the class it cannot find is in the gate.jar file, and it is either not on the new machine, or is not in the correct place on the new machine.
To expand slightly: Classes are found in a couple of places, but you specify a gate.jar on the classpath of the command line (that's what the -cp designates), so I'm guessing it's there. Since java can't find it, I'm guessing further that the necessary jar file is not where it needs to be for the Java runtime to find it.
For Linux and OSX use '/' and ':' , try this call .. it worked for me
java -cp './bin/*:../GATEFiles/lib/*:../GATEFiles/bin/gate.jar:./lib/*' code4goal.antony.resumeparser.ResumeParserProgram cv.pdf cv.json

Java URLClassNotFoundException over mounted Isilon connection

I am having trouble with mounted filesystems running a Blackboard Java application. We migrated resources from a VNX filesystem to an Isilon system. There is a mounted /content directory over which the local java must reach to access classes. When the older VNX system is connected the script / application run fine, but when the Isilon system is connected, the application breaks with the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Lists
at blackboard.apps.bbpatch.cli.CliLauncher.<clinit>(CliLauncher.java:31)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Lists
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)
... 1 more
As implied by the above summary, it's not a problem of not being in the classpath or the classpath being incorrectly specified. There is something in the data communication that must be tripping up this interaction, perhaps some kind of delay issue?
I am seeking advice on how to debug this problem.
Thank you

No class def found java

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/protocol/HttpContext
at com.amazonaws.AmazonWebServiceClient.<init>(AmazonWebServiceClient.java:119)
at com.amazonaws.AmazonWebServiceClient.<init>(AmazonWebServiceClient.java:103)
at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:362)
at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:344)
at Gethtml_fromS3.main(Gethtml_fromS3.java:16)
Caused by: java.lang.ClassNotFoundException: org.apache.http.protocol.HttpContext
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)
... 5 more
Can any one give me a solution for the above error?
Please check if you have httpcore jar. I got rid of this error, after adding httpcore-4.2.jar to my lib.
It's difficult to pinpoint the exact reason why your application raises this exception, but a few common pointers that might help you.
The exception is raised when you are using a class in your code that isn't available when it runs. In this case, it seems you are unable to use org.apache.http.protocol.HttpContext. Most likely, you created an application that does include the Amazon AWS jar, but lacks the Apache HTTPClient jar.
If you used gradle/maven to create your application, include it in your dependencies. It it's a plain Java program, ensure the required JARs are available in your classpath (e.g. the same place as you currently have the Amazon jar located).

Cannot Get JOGL to run, compiles fine but error during execution

I followed the installation here:
http://jogamp.org/wiki/index.php/Setting_up_a_JogAmp_project_in_your_favorite_IDE#IntelliJ_IDEA
and
http://jogamp.org/wiki/index.php/Downloading_and_installing_JOGL
I'm using IntelliJ IDEA Community 13. Everything compiles nicely but when i go to run the code i get the error:
Exception in thread "main" java.lang.ClassNotFoundException: com.helljogl.OneTriangleSwingGLJPanel
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)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113)
I have OpenGL and Java experience, but for some reason this is giving me a huge headache.
I've been at it for hours and have seen similar problems, but found no solutions...
Any ideas?
Rather than adding the dependencies to the project through the IDE, use maven (or Gradle). There's no need to manually download the jogl jar files and mess around with your classpath. See How to set up IntelliJIdea for development using JOGL on Linux and Windows?
After so many Installation Attempts I had jogl.jars all over the place. After cleaning up my environment everything is going smoothly!

Trouble setting up lucene on Mac OSX

I'm having a lot of trouble getting Lucene to work on Mac OS 10.7.5
I downloaded the binaries from http://lucene.apache.org/core/2_9_4/demo.html.
I changed my classpath
$ echo $CLASSPATH
/Users/me/Downloads/lucene-4.5.1/demo/lucene-demo-4.5.1.jar:/Users/me/Downloads/lucene-4.5.1/core/lucene-core-4.5.1.jar
Now I'm trying to run it.
$java org.apache.lucene.demo.IndexFiles /Users/me/Downloads/lucene-4.5.1/src
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/analysis/standard/StandardAnalyzer
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
at java.lang.Class.getMethod0(Class.java:2774)
at java.lang.Class.getMethod(Class.java:1663)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.analysis.standard.StandardAnalyzer
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)
... 6 more
It's not working. Can someone give me a step-by-step guide to getting up and running with Lucene. I have a simple task I want to do achieve, which is searching for text in a directory of files in a more efficient way than grep. Any help would be appreciated.
You'll also need to add two more jars to your classpath: lucene-analyzers-common-{version}.jar to fix this problem, and lucene-queryparser-{version}.jar to fix the next one. More recent demo documentation makes this clear (the documentation you linked to is for version 2.9.4)

Categories