multiple slf4j bindings in Eclipse RCP Plugin

拈花ヽ惹草 提交于 2019-12-13 12:03:43

问题


I have a simple Eclipse Plugin which gives me following error on activation:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [bundleresource://103.fwk8918249:1/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [bundleresource://103.fwk8918249:4/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

both URLs resolve to the exact same jar in the bundle

libs/slf4j-log4j12.jar!/org/slf4j/impl/StaticLoggerBinder.class
  • How can i solve the problem?
  • How come that the bundle loads the jar twice (":1" and ":4")?

回答1:


This is a result of defining an SLF4J binding in both your project's classpath (JDT .classpath file) and your MANIFEST.MF file.

You should remove your SLF4J binding from your project's class path:

YourProject → Properties → Java Build Path → Libraries

  • Select the SLF4J Binding JAR and hit 'Remove'.

Once you do this, there should only be a single reference to your SLF4J binding in your class loader (and thus the error message should not appear).




回答2:


For me the issue occurred due to an installed plugin. To find out which one it is.. look for the file SavedExternalPluginList.txt in the metadata of the debugging eclipse instance, e.g.

runtime-EclipseApplication\.metadata\.plugins\org.eclipse.pde.core\SavedExternalPluginList.txt

and search for slf4j. This way you get an idea which plugins might be responsible. I found following entries:

file:/D:/EclipseJava/App/Eclipse/plugins/ch.qos.logback.slf4j_1.0.7.v201505121915.jar

file:/D:/EclipseJava/App/Eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.7.0.20160603-1931/

file:/D:/EclipseJava/App/Eclipse/plugins/org.slf4j.api_1.7.2.v20121108-1250.jar
file:/D:/EclipseJava/App/Eclipse/plugins/org.slf4j.impl.log4j12_1.7.2.v20131105-2200.jar

Disabling the plugin ch.qos.logback.slf4j for my Target Platform did the trick:

If you manually change the plugin selection, please be careful and use the Validate Plug-ins feature to make sure you don't create other issues.




回答3:


This seems to solve the problem: SLF4J: Class path contains multiple SLF4J bindings

If not, do you have two different versions of SLF4J on that path?



来源:https://stackoverflow.com/questions/18721142/multiple-slf4j-bindings-in-eclipse-rcp-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!