我正在尝试解决此问题。
解决问题的步骤:
1):我已经下载了jDOM并转到eclipse->构建路径 - >库并添加了jar文件。
2):去了/ jre7 / lib / ext并添加了jdom-2.0.5.jar(这是最新版本)
3):将jar文件添加到classpath。
这是错误:
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代码:
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());
}
}
请帮助我,我做错了。我只是想解决这个问题。
问候。
答案 0 :(得分:1)
JDOM 2.x更改了JDOM方法和类的API,以包含通用构造,使其更加Java友好并使其保持最新。
所需的更改包括对系统API的更改。这打破了JDOM 1.x版本和JDOM 2.x版本之间的兼容性。
为了能够在更大的系统中拥有不同的库依赖关系,JDOM 2.x版本被更改为具有不同的包名称。
JDOM 1.x类都在包结构org.jdom.*
中,所有JDOM 2.x类都在包org.jdom2.*
中。
您的例外情况是:java.lang.NoClassDefFoundError: org/jdom/JDOMException
暗示您需要在类路径中使用JDOM 1.x版本。您需要download JDOM 1.1.3
或者,您需要找到JDOM依赖项并升级该代码以使用JDOM 2.x. It is not very hard
您应该从Java的ext目录中删除JDOM 2.0.5 jar。这不是放置依赖罐的正确位置。