Menu

NoClassDefFound error in Persistence, #10

Anonymous
2011-02-09
2013-04-09
  • Anonymous

    Anonymous - 2011-02-09

    When I try to run the compiled application from the command line, I see the 1st status report and then the following error message:

    Exception in thread "main" java.lang.NoClassDefFoundError: com/thoughtworks/xstream/io/HierarchicalStreamDriver
            at org.persistence.tutorial.MyLibrary.main(MyLibrary.java:140)
    Caused by: java.lang.ClassNotFoundException: com.thoughtworks.xstream.io.HierarchicalStreamDriver

    I'm assuming it is something to do with the manifest - I've tried moving the XStream…jar into the same folder as the rest of the project but that didn't work.  The app works perfectly from within Eclipse, so it has to be something to do with the deployment. Any thoughts?

    It would help if you could email back to ian.dennis@aerojet.com.  Thanks

     
  • Mark Dexter

    Mark Dexter - 2011-02-09

    It looks like you have not included the XStream library in your manifest. I would double-check your manifest with the one in the tutorial. I think this is it. Good luck. 

    Manifest-Version: 1.0
    Main-Class: org.persistence.tutorial.MyLibrary
    Class-Path: xstream-1.2.2.jar

     
  • Anonymous

    Anonymous - 2011-02-09

    My bad … I *had* included xstream in the manifest, but I had *not* copied the xstream.jar file to the export destination folder.

    Thank you for your prompt response, and for the quality of the tutorials.  After 44 years of coding, I am finally trying to wrap my brain round java.

     
  • Alex D'Amico

    Alex D'Amico - 2011-03-21

    Hello,

    Thanks for the great tutorial.

    I have been getting the same problem when I run the persistence.jar as mentioned by the original poster. It compiles fine in Eclipse, however, when I run persistence.jar I get the following error:

    Exception in thread "main" java.lang.NoClassDefFoundError: com/thoughtworks/xstream/io/HierarchicalStreamDriver
            at org.persistence.tutorial.MyLibrary.main(MyLibrary.java:140)
    Caused by: java.lang.ClassNotFoundException: com.thoughtworks.xstream.io.HierarchicalStreamDriver

    I have both the persistence.jar and the xstream-1.3.1.jar in the same directory. My manifest file is the following:

    Manifest-Version: 1.0
    Main-Class: org.persistence.tutorial.MyLibrary
    Class-Path: xstream-1.3.1.jar

    Is the Class-Path right since I downloaded the most recent 1.3.1.jar?

    Thanks for any help.

     
  • Mark Dexter

    Mark Dexter - 2011-03-21

    Hi. I haven't tried it with the newer XStream. I wonder if they perhaps made a change to the class name. You could try it with the older version of XStream to see if that works. If so, then you could look to see what changes they might have made. Good luck. Mark

     
  • Alex D'Amico

    Alex D'Amico - 2011-03-21

    I just attempted it with the older version of xstream-1.2.2.jar. Again it compiles fine, but when the .jar file is run, it doesn't seem to want to finish executing everything. Could it be a problem with my CLASSPATH? Though I thought I had read somewhere in attempting to resolve this problem, that running -jar makes the classpath the current directory.

    I am running Eclipse Java EE IDE for Web Developers. Version: Helios Service Release 2 Build id: 20110218-0911.

    Would running that version of eclipse cause a problem? I am using the Java perspective and not the Java EE perspective.

    Thanks for the quick reply, any other help would be greatly appreciated.

     
  • Mark Dexter

    Mark Dexter - 2011-03-21

    Hmm. I found this on the Java tutorials:
    An Example
    We want to load classes in MyUtils.jar into the class path for use in MyJar.jar. These two JAR files are in the same directory.

    We first create a text file named Manifest.txt with the following contents:

    Class-Path: MyUtils.jar

    Warning: The text file must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.

    Maybe as simple as that? Mark

     
  • Alex D'Amico

    Alex D'Amico - 2011-03-21

    Thanks a lot. Worked like a charm. I apologize if it's something I missed during the tutorial.

    Out of curiosity, what did you search for to come up with that answer?

     
  • Mark Dexter

    Mark Dexter - 2011-03-21

    Glad it worked. I googled java class-path manifest and clicked the Sun Java tutorials link. I find the official Sun Java tutorials to be extremely helpful. Also, JavaRanch is a great website for asking Java questions. Good luck. Mark

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.