10

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")?
Absurd-Mind
  • 7,884
  • 5
  • 35
  • 47

3 Answers3

5

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).

Community
  • 1
  • 1
jdknight
  • 1,801
  • 32
  • 52
3

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:

enter image description here

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.

Stefan
  • 10,010
  • 7
  • 61
  • 117
  • The file SavedExternalPluginList.txt is in the workspace of the "debugging" eclipse. Thanks for pointing to this file – jantje Jul 20 '18 at 23:39
0

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?

Community
  • 1
  • 1
Calon
  • 4,174
  • 1
  • 19
  • 30
  • This does not solve the problem since i don't use maven to build the classpath. Also in this question are two different jars (1.6.1 and 1.6.4), my problem is that the exact same jar is twice on the classpath. – Absurd-Mind Sep 12 '13 at 14:55
  • The bundlesource protocol uses "portnumbers" to distinguish between different jars. In your case that would be jar 1 and 4 which both contain org/slf4j/impl/StaticLoggerBinder.class. Do you habe some other slf5j/logback/someotherlogger jar in your application? – Calon Sep 13 '13 at 06:47
  • The bundle contains 4 jars in runtime classpath, slf4j-api, log4j, slf4j-log4j12 and a jar with some internal helper classes. The ports 1 and 4 resolve both to the slf4j-log4j12.jar. Tested with FileLocator. – Absurd-Mind Sep 13 '13 at 13:15