1

I am getting the following when I run my Web Server:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/Stefan/.m2/repository/org/slf4j/slf4j-log4j12/1.6.4/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/Stefan/.m2/repository/ch/qos/logback/logback-classic/0.9.30/logback-classic-0.9.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by 
log4j:ERROR [sun.misc.Launcher$AppClassLoader@57bd06bf] whereas object of type 
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [WebAppClassLoader=440633929@1a438a49].

I tried to exclude the /ch/qos/logback/logback-classic/ dependency. Here is the part from my pom.xml:

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.6.4</version>
    <exclusions>
        <exclusion>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </exclusion>
    </exclusions>
</dependency>

I have added this but after a Maven Update the result is still the same. How can I resolve this?

Stefan Falk
  • 23,898
  • 50
  • 191
  • 378

2 Answers2

1

The artifact slf4j-api does not seem to depend on ch.qos.logback:logback-classic. You can run mvn dependency:tree to determine from where logback-classic is coming from.

See https://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html.

M A
  • 71,713
  • 13
  • 134
  • 174
0

You have to look at two things here. 1. SLF dependency.

SLF4J API is designed to bind with one and only one underlying logging framework at a time. If more than one binding is present on the class path, SLF4J will emit a warning, listing the location of those bindings.

here. Which means, that there might be amother jar which is having dependency on logback-classic. So you have to find it out and exclude the dependency from all those in your classpath.

  1. The error is regarging log4j.You are using slf4j-api which is the basic option. However, two class loaders(WebAppClassLoader - Tomcat version and sun.misc.Launcher$AppClassLoader - the normal one look here) are loading different versions and there are trying to refer each other. So there might be an issue with the way you are running the application too.

Please clear the first issue, and see if all the required classes are loaded with the same classloader. You can use the link provided by @manouti to get an idea of dependency tree. See if this helps too. Happy Coding.

Community
  • 1
  • 1
Ramzy
  • 6,948
  • 6
  • 18
  • 30