문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top