我正在尝试将GATE嵌入到我的java项目中。我已经阅读了关于如何构建GATE独立应用程序的GATE指南。但是,我收到很多错误,说不能加载每个插件(ANNIE,Twitter等)的creole.xml。这是我的代码:
public class NERGate {
public NERGate(){}
public static void main(String args[]) throws GateException, MalformedURLException{
Gate.setGateHome(new File("/Applications/GATE_Developer_8.1"));
Gate.setPluginsHome(new File("/Applications/GATE_Developer_8.1/plugins"));
Gate.init();
}
}
以下是我的控制台上的输出:
Using /Applications/GATE_Developer_8.1 as GATE home
Using /Applications/GATE_Developer_8.1/plugins as installed plug-ins directory.
Using /Applications/GATE_Developer_8.1/gate.xml as site configuration file.
Using /Users/adibangun/.gate.xml as user configuration file
Using /Users/adibangun/.gate.session as user session file
edu.stanford.nlp.util.Function is available via both the system classpath and a plugin; the plugin classes will be ignored
edu.stanford.nlp.ling.CoreLabel is available via both the system classpath and a plugin; the plugin classes will be ignored
edu.stanford.nlp.trees.Tree is available via both the system classpath and a plugin; the plugin classes will be ignored
edu.stanford.nlp.trees.GrammaticalStructureFactory is available via both the system classpath and a plugin; the plugin classes will be ignored
edu.stanford.nlp.tagger.maxent.MaxentTagger is available via both the system classpath and a plugin; the plugin classes will be ignored
edu.stanford.nlp.process.LexedTokenFactory is available via both the system classpath and a plugin; the plugin classes will be ignored
CREOLE plugin loaded: file:/Applications/GATE_Developer_8.1/plugins/Stanford_CoreNLP/
Cannot load file:/Applications/GATE_Developer_8.1/plugins/Twitter/ CREOLE repository.
gate.util.GateException: couldn't open creole.xml
at gate.creole.CreoleRegisterImpl.registerDirectories(CreoleRegisterImpl.java:299)
at gate.creole.CreoleRegisterImpl.registerDirectories(CreoleRegisterImpl.java:317)
at gate.Gate.initCreoleRepositories(Gate.java:449)
at gate.Gate.init(Gate.java:220)
at thmeaticAnalysis.controller.NERGate.main(NERGate.java:29)
at thematicanalysis.GUI.Home.GateNERButtonActionPerformed(Home.java:169)
at thematicanalysis.GUI.Home.access$200(Home.java:24)
at thematicanalysis.GUI.Home$3.actionPerformed(Home.java:75)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.NoClassDefFoundError: Lpt/tumba/spell/SpellChecker;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at gate.creole.CreoleAnnotationHandler.processParameters(CreoleAnnotationHandler.java:502)
at gate.creole.CreoleAnnotationHandler.processCreoleResourceAnnotations(CreoleAnnotationHandler.java:343)
at gate.creole.CreoleAnnotationHandler.processAnnotationsForResource(CreoleAnnotationHandler.java:313)
at gate.creole.CreoleAnnotationHandler.processAnnotations(CreoleAnnotationHandler.java:283)
at gate.creole.CreoleAnnotationHandler.processAnnotations(CreoleAnnotationHandler.java:286)
at gate.creole.CreoleAnnotationHandler.processAnnotations(CreoleAnnotationHandler.java:269)
at gate.creole.CreoleRegisterImpl.processFullCreoleXmlTree(CreoleRegisterImpl.java:365)
at gate.creole.CreoleRegisterImpl.parseDirectory(CreoleRegisterImpl.java:348)
at gate.creole.CreoleRegisterImpl.registerDirectories(CreoleRegisterImpl.java:293)
... 43 more
Caused by: java.lang.ClassNotFoundException: pt.tumba.spell.SpellChecker
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 55 more
Cannot load file:/Applications/GATE_Developer_8.1/plugins/ANNIE/ CREOLE repository.
gate.util.GateException: couldn't open creole.xml
at gate.creole.CreoleRegisterImpl.registerDirectories(CreoleRegisterImpl.java:299)
at gate.creole.CreoleRegisterImpl.registerDirectories(CreoleRegisterImpl.java:317)
at gate.Gate.initCreoleRepositories(Gate.java:449)
at gate.Gate.init(Gate.java:220)
at thmeaticAnalysis.controller.NERGate.main(NERGate.java:29)
at thematicanalysis.GUI.Home.GateNERButtonActionPerformed(Home.java:169)
at thematicanalysis.GUI.Home.access$200(Home.java:24)
at thematicanalysis.GUI.Home$3.actionPerformed(Home.java:75)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.NoClassDefFoundError: Lpt/tumba/spell/SpellChecker;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at gate.creole.CreoleAnnotationHandler.processParameters(CreoleAnnotationHandler.java:502)
at gate.creole.CreoleAnnotationHandler.processCreoleResourceAnnotations(CreoleAnnotationHandler.java:343)
at gate.creole.CreoleAnnotationHandler.processAnnotationsForResource(CreoleAnnotationHandler.java:313)
at gate.creole.CreoleAnnotationHandler.processAnnotations(CreoleAnnotationHandler.java:283)
at gate.creole.CreoleAnnotationHandler.processAnnotations(CreoleAnnotationHandler.java:286)
at gate.creole.CreoleAnnotationHandler.processAnnotations(CreoleAnnotationHandler.java:269)
at gate.creole.CreoleRegisterImpl.processFullCreoleXmlTree(CreoleRegisterImpl.java:365)
at gate.creole.CreoleRegisterImpl.parseDirectory(CreoleRegisterImpl.java:348)
at gate.creole.CreoleRegisterImpl.registerDirectories(CreoleRegisterImpl.java:293)
... 43 more
Caused by: java.lang.ClassNotFoundException: pt.tumba.spell.SpellChecker
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 55 more
Cannot load file:/Applications/GATE_Developer_8.1/plugins/Tools/ CREOLE repository.
gate.util.GateException: couldn't open creole.xml
at gate.creole.CreoleRegisterImpl.registerDirectories(CreoleRegisterImpl.java:299)
at gate.creole.CreoleRegisterImpl.registerDirectories(CreoleRegisterImpl.java:317)
at gate.Gate.initCreoleRepositories(Gate.java:449)
at gate.Gate.init(Gate.java:220)
at thmeaticAnalysis.controller.NERGate.main(NERGate.java:29)
at thematicanalysis.GUI.Home.GateNERButtonActionPerformed(Home.java:169)
at thematicanalysis.GUI.Home.access$200(Home.java:24)
at thematicanalysis.GUI.Home$3.actionPerformed(Home.java:75)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.NoClassDefFoundError: Lpt/tumba/spell/SpellChecker;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at gate.creole.CreoleAnnotationHandler.processParameters(CreoleAnnotationHandler.java:502)
at gate.creole.CreoleAnnotationHandler.processCreoleResourceAnnotations(CreoleAnnotationHandler.java:343)
at gate.creole.CreoleAnnotationHandler.processAnnotationsForResource(CreoleAnnotationHandler.java:313)
at gate.creole.CreoleAnnotationHandler.processAnnotations(CreoleAnnotationHandler.java:283)
at gate.creole.CreoleAnnotationHandler.processAnnotations(CreoleAnnotationHandler.java:286)
at gate.creole.CreoleAnnotationHandler.processAnnotations(CreoleAnnotationHandler.java:269)
at gate.creole.CreoleRegisterImpl.processFullCreoleXmlTree(CreoleRegisterImpl.java:365)
at gate.creole.CreoleRegisterImpl.parseDirectory(CreoleRegisterImpl.java:348)
at gate.creole.CreoleRegisterImpl.registerDirectories(CreoleRegisterImpl.java:293)
... 43 more
Caused by: java.lang.ClassNotFoundException: pt.tumba.spell.SpellChecker
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 55 more
Cannot load file:/Applications/GATE_Developer_8.1/plugins/Stanford_CoreNLP/ CREOLE repository.
gate.util.GateException: couldn't open creole.xml
at gate.creole.CreoleRegisterImpl.registerDirectories(CreoleRegisterImpl.java:299)
at gate.creole.CreoleRegisterImpl.registerDirectories(CreoleRegisterImpl.java:317)
at gate.Gate.initCreoleRepositories(Gate.java:449)
at gate.Gate.init(Gate.java:220)
at thmeaticAnalysis.controller.NERGate.main(NERGate.java:29)
at thematicanalysis.GUI.Home.GateNERButtonActionPerformed(Home.java:169)
at thematicanalysis.GUI.Home.access$200(Home.java:24)
at thematicanalysis.GUI.Home$3.actionPerformed(Home.java:75)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.NoClassDefFoundError: Lpt/tumba/spell/SpellChecker;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at gate.creole.CreoleAnnotationHandler.processParameters(CreoleAnnotationHandler.java:502)
at gate.creole.CreoleAnnotationHandler.processCreoleResourceAnnotations(CreoleAnnotationHandler.java:343)
at gate.creole.CreoleAnnotationHandler.processAnnotationsForResource(CreoleAnnotationHandler.java:313)
at gate.creole.CreoleAnnotationHandler.processAnnotations(CreoleAnnotationHandler.java:283)
at gate.creole.CreoleAnnotationHandler.processAnnotations(CreoleAnnotationHandler.java:286)
at gate.creole.CreoleAnnotationHandler.processAnnotations(CreoleAnnotationHandler.java:269)
at gate.creole.CreoleRegisterImpl.processFullCreoleXmlTree(CreoleRegisterImpl.java:365)
at gate.creole.CreoleRegisterImpl.parseDirectory(CreoleRegisterImpl.java:348)
at gate.creole.CreoleRegisterImpl.registerDirectories(CreoleRegisterImpl.java:293)
... 43 more
Caused by: java.lang.ClassNotFoundException: pt.tumba.spell.SpellChecker
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 55 more
我想知道我的项目配置是否有错或奇怪,因为我尝试创建一个单独导入GATE的新项目,并且在使用Gate.init()初始化Gate时没有显示任何错误。此外,所有插件都是存在于我的/Applications/GATE_Developer_8.1/plugins上,带有自己的creole.xml。 有谁知道有什么问题?任何意见和建议将非常感谢。非常感谢:))
答案 0 :(得分:1)
The underlying error on all the plugins is the
java.lang.ClassNotFoundException: pt.tumba.spell.SpellChecker
This class is used by the Normalizer
PR in the Twitter
plugin. The most likely cause I can think of for this error is if you have (accidentally or deliberately) added the twitter.jar
from GATE's Twitter
plugin to the main classpath of your application without also adding the jaspell.jar
file that it depends on.
Ideally you should not include any plugin JAR files on your main application classpath, but simply let the JARs be loaded by the plugin mechanism in the same way as when you load the plugin into GATE Developer. This does mean that you can't make static compile-time references to any plugin classes, but in 99% of cases that is not necessary anyway. All the top-level interfaces like ProcessingResource
, LanguageAnalyser
, CorpusController
, etc. are contained in gate.jar
so you don't need to import
a particular PR class in your code to be able to execute it, you can simply cast to LanguageAnalyser
.