"main" java.lang.NoClassDefFoundError: org/jdom/JDOMException

10,550

JDOM 2.x changes the API of the JDOM methods and classes to include generic constructs that makes it much more Java friendly and keeps it up to date.

The changes required included changes to the API for the system. The breaks the compatibility between JDOM 1.x versions and JDOM 2.x versions.

In order to make it possible to have different library dependencies in bigger systems, the JDOM 2.x version was changed to have a different package name.

JDOM 1.x classes are all in the package structure org.jdom.* and all JDOM 2.x classes are in the package org.jdom2.*.

The exception you have is: java.lang.NoClassDefFoundError: org/jdom/JDOMException

The implies that you need to have JDOM 1.x version in your classpath. You need to download JDOM 1.1.3

Alternatively you need to locate your JDOM dependency and upgrade that code to use JDOM 2.x. It is not very hard.

You should remove the JDOM 2.0.5 jar from the ext directory of Java. That is not the right place to put dependency jars.

Share:
10,550
Dark Knight
Author by

Dark Knight

I'm a Software Engineering student trying to explore adventure and new ways to solve a problem (and ofcourse ask questions in between ;) )

Updated on June 04, 2022

Comments

  • Dark Knight
    Dark Knight almost 2 years

    I am trying to resolve this issue.

    Steps taken to resolve the issue:

    1): I have downloaded jDOM and went to eclipse->build path-> libraries and added the jar file.

    2): Went to /jre7/lib/ext and added jdom-2.0.5.jar (Which is the latest version)

    3): Added the jar file to classpath.

    This is the error:

    start initialization...
    log4j:WARN No appenders could be found for logger (gate.Gate).
    log4j:WARN Please initialize the log4j system properly.
    log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
    Exception in thread "main" java.lang.NoClassDefFoundError: org/jdom/JDOMException
        at gate.Gate.init(Gate.java:216)
        at yelpMongo.YelpGate.<init>(YelpGate.java:44)
        at yelpMongo.YelpGate.getInstance(YelpGate.java:71)
        at yelpMongo.YelpGate.main(YelpGate.java:115)
    Caused by: java.lang.ClassNotFoundException: org.jdom.JDOMException
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
    

    Java Code:

    import gate.Gate;
    import gate.Corpus;
    import gate.Factory;
    import static gate.util.persistence.PersistenceManager.loadObjectFromFile;
    
    public class YelpGate {
    
        // remember create log4j.properties file under project dir!!!
        String homeDir = "C:/Program Files/GATE_Developer_7.1/";
        String ruleDir = "C:/Users/Rupesh/workspace/YelpMongo/Yelp/yelp.xgapp";
    
        // used for corpus control
        private static gate.CorpusController ctrl;
    
        // singleton
        private static YelpGate instance = null;
    
        /*
         * constructor of YelpGate, load Gate Plugins when initializaion
         */
        private YelpGate()
        {
            System.out.println("start initialization...");
            try {
                if (Gate.getGateHome() == null)
                {
                    Gate.setGateHome(new File(homeDir));
                }
    
                Gate.init();
                Gate.getCreoleRegister().registerDirectories(
                        new File(homeDir + "plugins", "ANNIE").toURI().toURL());
    
                //For Only if you are using this plugin
                Gate.getCreoleRegister().registerDirectories(
                        new File(homeDir + "plugins", "Tools").toURI().toURL());
    
                ctrl = ((gate.CorpusController)
                        loadObjectFromFile(new java.io.File(ruleDir)));
    
            } catch (Exception e){
                System.out.println(e.getMessage());
            }
        } 
    

    Please help me where i'm doing wrong. I just want to resolve this issue.

    Regards.

  • Dark Knight
    Dark Knight about 10 years
    Ur so right.Now I get one more Exception in thread "main" java.lang.NoClassDefFoundError: org/pdfbox/util/PDFTextStripper at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Unknown Source) at java.lang.Class.getDeclaredMethods(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.pdfbox.util.PDFTextStripper at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) But I seem to have fontbox.jar and pdfbox.jar both on my class.
  • rolfl
    rolfl about 10 years
    This will be something else entirely. JDOM does not use pdfbox in any way, so it is not JDOM related.
  • Dark Knight
    Dark Knight about 10 years
    I thought for a moment that it's related to jar's. changed the jar versions in my class path. But still the same. Thanks for your help :)