我正在使用GATE工具进行文本分析,并且在安装PR时出现以下错误-
SLF4J:slf4j绑定所请求的1.5.6版本与[1.6,1.7]不兼容
现在,我已经在互联网上搜索了此内容,并发现了以下内容-
Mixing different versions of slf4j-api.jar and SLF4J binding can cause problems. For example, if you are using slf4j-api-1.7.2.jar, then you should also use slf4j-simple-1.7.2.jar, using slf4j-simple-1.5.5.jar will not work.
我正在使用slf4j-api-1.7.12,但是此文件slf4j-simple-N在我的计算机上不存在。我该如何解决这个问题?任何帮助将不胜感激。谢谢!
编辑:问题不再存在于GATE 8.4中,其中GATE中的类加载确实允许每个插件分开,因此一个插件加载的库不会干扰另一个插件加载的库。
我认为,我可以重现该问题。当两个插件被加载并且每个插件使用不同版本的时,它就会在GATE Developer中体现出来slf4j-api
。例如,本体插件正在使用slf4j 1.5.6
和Stanford_CoreNLP slf4j 1.7.12
。
当尝试创建Stanford POS Tagger的新实例时,它最终显示以下错误消息(请参见完整的日志行):
java.lang.LinkageError:违反加载程序约束:解决方法“ org.slf4j.impl ...”时
GATE 8.2 build 5482 started at Mon Jul 04 21:54:09 CEST 2016
and using Java 1.8.0_91 Oracle Corporation on Windows 8.1 amd64 6.3.
CREOLE plugin loaded: file:/C:/Program%20Files/gate-8.2-build5482-BIN/plugins/Stanford_CoreNLP/
CREOLE plugin loaded: file:/C:/Program%20Files/gate-8.2-build5482-BIN/plugins/Ontology/
org.xml.sax.helpers.DefaultHandler is available via both the system classpath and a plugin; the plugin classes will be ignored
SLF4J: The requested version 1.5.6 by your slf4j binding is not compatible with [1.6, 1.7]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;" the class loader (instance of gate/util/GateClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of gate/util/GateClassLoader) for the method's defining class, org/slf4j/impl/StaticLoggerBinder, have different Class objects for the type org/slf4j/ILoggerFactory used in the signature
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:335)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:283)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:304)
at edu.stanford.nlp.io.IOUtils.<clinit>(IOUtils.java:42)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTagger.java:765)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:298)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:263)
at gate.stanford.Tagger.init(Tagger.java:129)
at gate.Factory.createResource(Factory.java:432)
at gate.gui.NewResourceDialog$4.run(NewResourceDialog.java:270)
at java.lang.Thread.run(Unknown Source)
我可以想到三种可能的解决方案:
您是否真的需要两个插件都具有不兼容的slf4j版本?如果不是这样,只需卸载不需要的插件(确保重新启动GATE),问题就应该解决了。
这个解决方案比下一个解决方案要脏得多(因为修改后的插件无法单独使用),但作为快速解决方案就足够了。选择一个插件,然后从插件的creole.xml
文件中删除slf4j条目。同样,在GATE重新启动后,该问题仍将消失。
对于Ontology插件,这非常容易:(请注意注释掉的行)
<?xml version="1.0"?>
<CREOLE-DIRECTORY>
<JAR>lib/commons-httpclient-3.1.jar</JAR>
<JAR>lib/owlim-lite-5.4.jar</JAR>
<!-- <JAR>lib/slf4j-api-1.5.6.jar</JAR>
<JAR>lib/slf4j-jdk14-1.5.6.jar</JAR> -->
<JAR>lib/openrdf-sesame-2.7.9-onejar.jar</JAR>
<JAR SCAN="true">Ontology.jar</JAR>
</CREOLE-DIRECTORY>
对于Stanford_CoreNLP插件,它更加复杂,因为它正在使用Apache Ivy加载slf4j jar ,并且必须将它们排除在ivy.xml
文件中(plugins\Stanford_CoreNLP\build\ivy.xml
请注意<exclude org="org.slf4j"/>
,在文件底部添加了一行)
<ivy-module version="2.0">
<info
organisation="uk.ac.gate.plugins"
module="stanford_corenlp"
revision="8.2-SNAPSHOT">
<description homepage="https://github.com/GateNLP/gateplugin-Stanford_CoreNLP/" />
</info>
<configurations>
<conf name="default" />
</configurations>
<dependencies defaultconf="*->master(default),runtime(default)" >
<dependency org="edu.stanford.nlp" name="stanford-corenlp" rev="3.6.0" />
<exclude org="org.slf4j"/>
</dependencies>
</ivy-module>
这似乎是一个干净的解决方案,但是它比我预期的要复杂得多,因为即使两个插件都使用相同版本的slf4j,问题仍然存在。问题可能更深层地存在于GATE类加载机制内部,唯一的“为我工作的方式”如何统一slf4j版本是将它们排除在所有有冲突的插件中,并添加slf4j jar(例如来自Ontology插件的jar) )到GATE的lib
文件夹。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句