Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude jar that contains StaticLoggerBinder from activemq-all maven dependency?

I'm using ActiveMQ (an apache camel component) to send SMS from web to GSM mobile, so I needed to use SLF4J. I got this in the output of my netbeans project when i run it it seems like the jar is present two times, and i think that i need to add an exclusion in the dependency in my pom.xml but i dont know what to do exactly !

This is the part of SLF4 in my pom.xml:

<!-- logging -->
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.7.5</version>

    <!--  <exclusions>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </exclusion>
    </exclusions> -->
</dependency>

And this is my output while running my project

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/asus/.m2/repository/org/apache/activemq/activemq-all/5.9.0/activemq-all-5.9.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/asus/.m2/repository/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.7.5.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.Log4jLoggerFactory]
like image 514
NoKHe Avatar asked Jan 09 '23 21:01

NoKHe


2 Answers

Try the following:

<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-all</artifactId>
    <version>5.9.0</version>
    <type>pom</type>
</dependency>

See more in [AMQ-5009] Switch activemq-all from shaded jar to pom dependency aggregator - ASF JIRA.

like image 99
Paul Vargas Avatar answered Jan 14 '23 23:01

Paul Vargas


Your question is lacking a bit of context, but I'd say you should simply drop that slf4j-log4j12 dependency from your POM, since an SLF4J binding is embedded in activemq-all-5.9.0.jar anyway.

Or maybe you could try not using activemq-all with embedded dependencies and use individual ActiveMQ artifacts with ordinary transitive dependencies.

like image 20
Harald Wellmann Avatar answered Jan 14 '23 23:01

Harald Wellmann