简体   繁体   English

“主要” java.lang.NoClassDefFoundError:org / jdom / JDOMException

[英]“main” java.lang.NoClassDefFoundError: org/jdom/JDOMException

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. 1):我已经下载了jDOM并转到eclipse-> build path->库并添加了jar文件。

2): Went to /jre7/lib/ext and added jdom-2.0.5.jar (Which is the latest version) 2):转到/ jre7 / lib / ext并添加了jdom-2.0.5.jar(这是最新版本)

3): Added the jar file to classpath. 3):将jar文件添加到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: Java代码:

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. JDOM 2.x更改了JDOM方法和类的API,以包含通用构造,从而使其对Java更加友好并保持最新。

The changes required included changes to the API for the system. 所需的更改包括对系统API的更改。 The breaks the compatibility between JDOM 1.x versions and JDOM 2.x versions. 中断了JDOM 1.x版本和JDOM 2.x版本之间的兼容性。

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 2.x版本已更改为具有不同的程序包名称。

JDOM 1.x classes are all in the package structure org.jdom.* and all JDOM 2.x classes are in the package org.jdom2.* . JDOM 1.x类都在包结构org.jdom.* ,所有JDOM 2.x类都在包org.jdom2.*

The exception you have is: java.lang.NoClassDefFoundError: org/jdom/JDOMException 您遇到的异常是: java.lang.NoClassDefFoundError: org/jdom/JDOMException

The implies that you need to have JDOM 1.x version in your classpath. 这意味着您需要在类路径中具有JDOM 1.x版本。 You need to download JDOM 1.1.3 您需要下载JDOM 1.1.3

Alternatively you need to locate your JDOM dependency and upgrade that code to use JDOM 2.x. 或者,您需要找到JDOM依赖关系并升级该代码以使用JDOM2.x。 It is not very hard . 这不是很难

You should remove the JDOM 2.0.5 jar from the ext directory of Java. 您应该从Java的ext目录中删除JDOM 2.0.5 jar。 That is not the right place to put dependency jars. 那不是放置依赖罐的正确位置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.NoClassDefFoundError: org/jdom2/JDOMException 和 java.lang.ClassNotFoundException for xmldsig - java.lang.NoClassDefFoundError: org/jdom2/JDOMException and java.lang.ClassNotFoundException for xmldsig 线程“ main”中的异常java.lang.noClassDefFoundError org / jdom / input / SAXBuilder - Exception in thread “main” java.lang.noClassDefFoundError org/jdom/input/SAXBuilder java.lang.ClassNotFoundException:org.jdom.JDOMException - java.lang.ClassNotFoundException: org.jdom.JDOMException javax.servlet.ServletException:java.lang.NoClassDefFoundError:org / jdom2 / input / SAXBuilder - javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/jdom2/input/SAXBuilder 线程“ main”中的异常java.lang.NoClassDefFoundError:org / mockito / Mockito - Exception in thread “main” java.lang.NoClassDefFoundError: org/mockito/Mockito 线程“main”中的异常java.lang.NoClassDefFoundError:org / json / JSONObject - Exception in thread “main” java.lang.NoClassDefFoundError: org/json/JSONObject 线程“ main”中的异常java.lang.NoClassDefFoundError:org / javatuples / Unit - Exception in thread “main” java.lang.NoClassDefFoundError: org/javatuples/Unit 线程“main”中的异常 java.lang.NoClassDefFoundError: org/hamcrest/Matchers - Exception in thread "main" java.lang.NoClassDefFoundError: org/hamcrest/Matchers “主要” java.lang.NoClassDefFoundError:org / apache / http / HttpEntity - “main” java.lang.NoClassDefFoundError: org/apache/http/HttpEntity “线程”main“中的异常 java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing” - “Exception in thread ”main“ java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM