【发布时间】:2014-08-05 20:00:08
【问题描述】:
我是 GATE、ANNIE 和信息提取 (IE) 的新手。我正在尝试使用 ANNIE 来做一些 IE。我在 Ubuntu 14.* 上安装了 GATE,GATE Developer 8 运行良好。我正在尝试在 Eclipse(Luna)中使用我的 Java(JDK 1.8)项目中的 GATE Embedded。我创建了一个用户库来添加必要的 GATE jar(gate.jar 和 Lib 中的所有 jar)来构建路径。我使用
添加了 gate.home 系统属性System.setProperty("gate.home", "/home/haree/GATE_Developer_8.0");
我尝试了 GATE link 上提供的示例,但我遇到了以下我无法修复的空指针异常。
输出:
Initialising GATE...
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.NullPointerException
at gate.util.Files.getResource(Files.java:399)
at gate.util.Files.getGateResource(Files.java:419)
at gate.Gate.init(Gate.java:178)
at sheffield.examples.TestGate.main(TestGate.java:16)
我注意到异常是由 - Gate.init() 方法调用引起的。我编写了一个简单的类,调用了上述方法,并使用了该系统属性(gate.home)等,但没有用。我不知何故觉得异常是在 GATE API 试图读取安装目录中的 gate.xml 文件时引起的。我把它和我写的代码一起复制到这里。任何解决此问题的帮助表示赞赏。
代码:
package sheffield.examples;
import gate.Gate;
import gate.util.GateException;
import gate.util.Out;
public class TestGate {
public static void main(String[] args) {
// initialise the GATE library
Out.prln("Initialising GATE...");
System.setProperty("gate.home", "/home/haree/GATE_Developer_8.0");
try {
Gate.init();
} catch (GateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Out.prln("...GATE initialised");
}
}
gate.xml 文件:
<?xml version="1.0"?>
<!-- gate.xml -->
<!-- $Id: gate.xml 17080 2013-11-12 19:29:34Z markagreenwood $ -->
<!-- any entries in this file will be processed at Gate.init()
time - i.e. will appear in every GATE invocation -->
<GATE>
<GATECONFIG Save_options_on_exit="true" Save_session_on_exit="true"/>
</GATE>
注意:我在 Google 上搜索并找到了这个 link,它讨论了同样的问题,但对我没有帮助
更多信息:
我配置了之前忽略的 log4j,日志如下所示:
Initialising GATE...
18:49:37 INFO [main] - gate.Gate.initLocalPaths - Using /home/haree/GATE_Developer_8.0 as GATE home
18:49:37 INFO [main] - gate.Gate.initLocalPaths - Using /home/haree/GATE_Developer_8.0/plugins as installed plug-ins directory.
18:49:37 INFO [main] - gate.Gate.initLocalPaths - Using /home/haree/GATE_Developer_8.0/gate.xml as site configuration file.
18:49:37 INFO [main] - gate.Gate.initLocalPaths - Using /home/haree/.gate.xml as user configuration file
18:49:37 INFO [main] - gate.Gate.initLocalPaths - Using /home/haree/.gate.session as user session file
Exception in thread "main" java.lang.NullPointerException
at gate.util.Files.getResource(Files.java:399)
at gate.util.Files.getGateResource(Files.java:419)
at gate.Gate.init(Gate.java:178)
at sheffield.examples.TestGate.main(TestGate.java:16)
我读到 GATE 在用户主目录中创建/使用两个配置文件,即:1)gate.xml & 2)gate.session
由于某种原因,我在主目录中找不到这两个文件(我是 Ubuntu 文件系统的新手),不确定它们是否是隐藏文件。
【问题讨论】:
标签: eclipse nullpointerexception java-8 gate information-extraction