3

I've seen in other questions that usually the solution to this warning is to exclude slf4j from the dependency that causes this conflict, but I can't spot the problem in my project.

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]

I run mvn dependency:tree command and this is the output:

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ subscriptionsmanager ---
[INFO] it.pietro:subscriptionsmanager:jar:0.0.1-SNAPSHOT
[INFO] +- junit:junit:jar:4.13.1:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.mockito:mockito-core:jar:3.5.13:test
[INFO] |  +- net.bytebuddy:byte-buddy:jar:1.10.15:test
[INFO] |  +- net.bytebuddy:byte-buddy-agent:jar:1.10.15:test
[INFO] |  \- org.objenesis:objenesis:jar:3.1:test
[INFO] +- org.mongodb:mongo-java-driver:jar:3.12.7:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  +- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- de.bwaldvogel:mongo-java-server:jar:1.11.1:compile
[INFO] |  +- de.bwaldvogel:mongo-java-server-core:jar:1.11.1:compile
[INFO] |  |  +- io.netty:netty-transport:jar:4.1.31.Final:compile
[INFO] |  |  |  +- io.netty:netty-buffer:jar:4.1.31.Final:compile
[INFO] |  |  |  |  \- io.netty:netty-common:jar:4.1.31.Final:compile
[INFO] |  |  |  \- io.netty:netty-resolver:jar:4.1.31.Final:compile
[INFO] |  |  \- io.netty:netty-codec:jar:4.1.31.Final:compile
[INFO] |  \- de.bwaldvogel:mongo-java-server-memory-backend:jar:1.11.1:compile
[INFO] +- org.assertj:assertj-core:jar:3.15.0:test
[INFO] +- org.testcontainers:mongodb:jar:1.15.1:compile
[INFO] |  \- org.testcontainers:testcontainers:jar:1.15.1:compile
[INFO] |     +- org.apache.commons:commons-compress:jar:1.20:compile
[INFO] |     +- org.rnorth.duct-tape:duct-tape:jar:1.0.8:compile
[INFO] |     +- org.rnorth.visible-assertions:visible-assertions:jar:2.1.2:compile
[INFO] |     |  \- net.java.dev.jna:jna:jar:5.2.0:compile
[INFO] |     +- com.github.docker-java:docker-java-api:jar:3.2.7:compile
[INFO] |     |  \- com.fasterxml.jackson.core:jackson-annotations:jar:2.10.3:compile
[INFO] |     \- com.github.docker-java:docker-java-transport-zerodep:jar:3.2.7:compile
[INFO] |        \- com.github.docker-java:docker-java-transport:jar:3.2.7:compile
[INFO] +- org.assertj:assertj-swing-junit:jar:3.17.1:test
[INFO] |  +- org.assertj:assertj-swing:jar:3.17.1:test
[INFO] |  |  \- org.easytesting:fest-util:jar:1.2.5:test
[INFO] |  \- org.easytesting:fest-reflect:jar:1.4.1:test
[INFO] \- info.picocli:picocli:jar:4.5.2:compile

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
pzsette
  • 286
  • 1
  • 5
  • 19
  • 2
    Does this answer your question? [SLF4J: Class path contains multiple SLF4J bindings](https://stackoverflow.com/questions/14024756/slf4j-class-path-contains-multiple-slf4j-bindings) – Sambit Feb 16 '21 at 13:44
  • Yes, but I do not understand what dependency causes the conflict. – pzsette Feb 16 '21 at 14:44
  • Given one of the paths mentioned is from Eclipse, I'd guess the problem is with Eclipse adding something extra on the path. – Mark Rotteveel Feb 16 '21 at 14:48
  • @MarkRotteveel Can you give an example where Eclipse does this? – howlger Feb 16 '21 at 15:50
  • After changing the `pom.xml`, did you right-click the project and _Maven > Update Project..._? Please show the command line executed by Eclipse (in the run configuration there is a _Show Command Line_ button for that). – howlger Feb 16 '21 at 15:52
  • @howlger I can't, I don't use Eclipse, I just notice that both paths in the message are inside the Eclipse application, one of them OSGi, and one of m2eclipse. I guess the m2eclipse one is from Maven, I don't know where the OSGi one is coming from. – Mark Rotteveel Feb 16 '21 at 16:48
  • @MarkRotteveel I don't believe Eclipse adds something extra on the path. See my answer below. – howlger Feb 16 '21 at 20:43

2 Answers2

3

The SLF4J bindings warning comes from the Eclipse IDE itself and is not related to your application you write in the Eclipse IDE. So it's just noise that can be ignored (see e.g. here and here).

I guess you have the Eclipse IDE for Enterprise Java Developers with maybe some additional plugins installed. That's more than 900 JARs. SLF4J is used by the Maven support for Eclipse (in the SLF4J bindings warning as m2e) and also by at least one other plugin in an incompatible way causing this warnings. Eclipse is based on OSGi where there is not a flat classpath and where plugins/bundles can be installed, started, stopped and uninstalled at runtime. SLF4J seems not to build with OSGi in mind, hence the misleading warning Class path contains multiple SLF4J bindings, although there is no classpath in OSGi which uses its own class loader instead.

howlger
  • 31,050
  • 11
  • 59
  • 99
-1

You can solve the issue by adding the following exclusion in the dependencies (of pom.xml) that caused conflict.

 <exclusions>
    <exclusion>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
    </exclusion>
 </exclusions> 
UdayKiran Pulipati
  • 6,579
  • 7
  • 67
  • 92
tapsshore
  • 272
  • 4
  • 9