SLF4J: slf4j-api 1.6.x (or later) is incompatible with this binding
17,413
Solution 1
I had to excluded the slf4j depenedencies from the dozer library and add dependencies directly to the POM file.
As mentioned by @Powerlord, i had to add two libraries, one for the core slf4j and the other one is a binding library.
Maven dependencies below.
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
<version>5.5.1</version>
<exclusions>
<exclusion>
<artifactId>jcl-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
Solution 2
SLF4J is statically bound based on dependency.
If you are using log4j, you should have the log4j binding in your application.
Even if you are not using slf4j you will need to have a binding (simple or noop) to get it to load properly from a dependent library.
Related videos on Youtube
Author by
Zeus
Updated on October 26, 2022Comments
-
Zeus over 1 year
2015-09-28 10:02:21,890 ERROR [STDERR] (HDScanner) SLF4J: slf4j-api 1.6.x (or later) is incompatible with this binding. 2015-09-28 10:02:21,891 ERROR [STDERR] (HDScanner) SLF4J: Your binding is version 1.5.5 or earlier. 2015-09-28 10:02:21,891 ERROR [STDERR] (HDScanner) SLF4J: Upgrade your binding to version 1.6.x. 2015-09-28 10:02:21,891 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/metasolv-web]] (HDScanner) Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener java.lang.NoSuchMethodError: org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg/slf4j/impl/StaticLoggerBinder;
How do I fix this error? Also, in my application, I do not use slf4j anywhere, only the Dozer library uses it. from the below stacktrace I see that the spring application is using the slf4j, but why does it not load one on its own?
java.lang.NoSuchMethodError: org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg/slf4j/impl/StaticLoggerBinder; at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269) at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156) at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:645) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:191)
-
Powerlord over 8 yearsIt helps if you know that slf4j has two layers. The first is the core. The second is the bindings. It sounds like the core is version 1.6 or higher while the binding in question is version 1.5.5 or lower.
-
Powerlord over 8 yearsIf the slf4j files are in your
WEB-INF/lib
directory, you could swap out the slf4j binding jar for a newer version. Alternately, if you're using Maven/Gradle, you could specify a newer version of the binding. -
Zeus over 8 years@Powerlord You have helped me fix the issue, i've added another dependency
slf4j-simple
(binding) and excluded the ones that is available in the dozer library. If you add your answer below, I'll mark it as answered.
-
-
Zeus over 8 yearsFrom the above error, i see that I need the slf4j library, but even when i loaded 1.5.5 or 1.7.5 version of the library, it does not get rid of the above error.
-
Dave G over 8 yearsSee if adding this dependency in addition to the slf4j-api helps mvnrepository.com/artifact/org.slf4j/slf4j-simple