5

I am facing this error while running my GWT application.

I have these jar files in my classpath: slf4j-api & slf4j-log4j12

Any idea what could be the reason?

Mat
  • 202,337
  • 40
  • 393
  • 406
junaidp
  • 10,801
  • 29
  • 89
  • 137

2 Answers2

21

This problem is due to a change in slf4j-log4j12 jar. From version 1.5.6 it doesn't allow to access the field org.slf4j.impl.StaticLoggerBinder.SINGLETON.

To resolve it, use the newest jars (or at least version 1.5.6 onward) for both slf4j-api & slf4j-log4j12.

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.5.6</version>
</dependency>

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.5.6</version>
</dependency>
drone.ah
  • 1,135
  • 14
  • 28
bnguyen82
  • 6,048
  • 5
  • 30
  • 39
  • 2
    I have been plagued by SLF4J backwards-compatibility issues so much I could scream. What a ridiculous API. I will never intentionally use SLF4J. I hate it. That said, thank you for the answer. :) – Bane Apr 20 '14 at 00:01
  • 1
    @Bane same with me.I've spend too much time on SLF4J issues. – oyss Jan 30 '18 at 08:01
1

Finally resolved this problem in my SpringBoot application. If updating version is not helping this might help. Sometimes other libraries might bring different versions of this dependencies. These are the steps:

  1. By error stack trace figure out which dependency is giving this issue
  2. Get maven dependency plugin tree. Using this tree details find out if this library is coming as part of the some other dependency. In my case, the logback-classic and log4j-over-slf4j were giving this problem. They came together under spring-boot-starter-web
  3. Use <exclusions><exclusion></exclusion></exclusions> in your pom.xml in that dependency for the libraries that giving this issue. In my case it looks like this:
         <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>logback-classic</artifactId>
                    <groupId>ch.qos.logback</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>log4j-over-slf4j</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
            </exclusions>
        </dependency>

References:
http://www.slf4j.org/faq.html#IllegalAccessError
http://www.slf4j.org/codes.html#multiple_bindings

Beknazar
  • 65
  • 9