1

In my project, i am using :

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.2</version>
    </dependency>

I can not remove it, because a lot of other dependencies use it. App is working with LDAP,so ecently i have add:

    <dependency>
        <groupId>org.apache.directory.server</groupId>
        <artifactId>apacheds-all</artifactId>
        <version>1.5.5</version>
    </dependency>

Which is depends from:

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.5.2</version>
    </dependency>

And now i have a lot of errors:

java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.error(SLF4JLocationAwareLog.java:225)

Can you please help me? Yep, I see this question

Community
  • 1
  • 1
Java Dude
  • 454
  • 6
  • 24

2 Answers2

3

You could:

  • Update your version to 1.5.7 which is the latest 1.x version. It depends on slf4j-log4j12:1.5.10, so this unlikely will help.
  • Consider using apacheds-all:2.0.0-M15. It depends on slf4j-log4j12:1.7.5 so if this version suits you, it should resolve this problem.

UPDATE

Some other ideas:

  • Decouple ApacheDS from Spring
  • or Disable logging for the problematic packages which use the old 1.5.x bridge
  • or Remove this bridge (by excluding a dependency) and (optionally) add log4j configuration to see log4j logs (never tried having them both!).
Andrey Chaschev
  • 16,160
  • 5
  • 51
  • 68
  • Thank you Andrey. Comment to second part: I can not use new version of apache-ds, because I am using (apache-ds) with scring. http://docs.spring.io/spring-security/site/docs/3.1.4.RELEASE/reference/appendix-dependencies.html. Spring can work only with 1.5.5 :( – Java Dude Nov 29 '13 at 12:29
  • Some other ideas: decouple this from Spring OR disable logging for the problematic packages which use the old `1.5.x` bridge OR remove this bridge (by excluding a dependency) and (optionally) add log4j configuration to see log4j logs (never tried having them both!). – Andrey Chaschev Nov 29 '13 at 12:44
1

Maven should be picking the latest version, but you could try adding a dependency management section, to explicitly specify which version of slf4j you want. Probably picking the most recent version out of all your various dependencies will be fine (1.7.2 in this case).

Alternatively, I've come across this issue when deploying an application into jboss, because it bundles an old version of slf4j, which takes precedence over the version in my application. You can check this by running your application (or jboss or whatever) with the -verbose:class jvm parameter, it will log out where each class is being loaded from. This would tell you if it's being loaded from the jar in your application, or something in your environment.

stripybadger
  • 4,539
  • 3
  • 19
  • 26