Java Dude
Java Dude

Reputation: 596

Logger dependencies in maven project

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

Upvotes: 1

Views: 3679

Answers (2)

stripybadger
stripybadger

Reputation: 5009

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.

Upvotes: 1

Andrey Chaschev
Andrey Chaschev

Reputation: 16516

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!).

Upvotes: 3

Related Questions