I have a problem with conflicting dependencies in my project. Particularly, there are two implementations of slf4j logging: slf4j-simple and logback-classic, and I'm getting
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/apykhtin/.m2/repository/org/slf4j/slf4j-simple/1.7.19/slf4j-simple-1.7.19.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/apykhtin/.m2/repository/ch/qos/logback/logback-classic/1.1.3/logback-classic-1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
Exception in thread "main" java.lang.IllegalStateException: Unable to acquire the logger context
at io.dropwizard.logging.LoggingUtil.getLoggerContext(LoggingUtil.java:46)
at runtime.
logback-classic is a must-have dependency for me (because of dropwizard), but slf4j-simple is not really, and I'd like to drop it from my uber project. Only it's not that easy.
My "uber jar" has a dependency on "small jar", which, in turn, has a dependency on "slf4j-simple". Putting an exclusion in uber jar's pom is not helping:
<dependency>
<groupId>com.my.unique.group</groupId>
<artifactId>small-jar</artifactId>
<version>0.1.2-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
I think because small-jar is "shaded". My "uber-jar" is using maven-shade-plugin, while "small-jar" is not. I also tried to exclude slf4j-simple from shading:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.6</version>
<configuration>
<artifactSet>
<excludes>
<exclude>org.slf4j:slf4j-simple:jar</exclude>
</excludes>
</artifactSet>
...
</plugin>
but also without success. slf4j-simple still gets included in my uber-jar. So far my development was all related to "uber-jar". It is possible for me to make changes to "small-jar" code, but I'd like to avoid that.
What am I doing wrong?