I am getting the following runtime error after adding activemq to my build.gradle.
compile("org.apache.activemq:activemq-all:5.14.0")
I have tried to exclude modules, but that does not seem exclude the logback like I expected. Please advise on what I can do to exclude logback. One other note, this is a kotlin application, however I don't think this is relevant.
compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
{
exclude module: "spring-boot-starter-logging"
exclude module: "logback-classic"
}
Here is the exception:
Exception in thread "main" java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.Log4jLoggerFactory loaded from file:/C:/Users/z037640/.gradle/caches/modules-2/files-2.1/org.apache.activemq/activemq-all/5.14.0/858a3bd95d20e7a8949006cdb50a7c362f8825ec/activemq-all-5.14.0.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml Object of class [org.slf4j.impl.Log4jLoggerFactory] must be an instance of class ch.qos.logback.classic.LoggerContext
If you don't want to use logback as a logger, then you just have to exclude it from all configurations , as follows:
configurations.all {
exclude group: "ch.qos.logback"
}
dependencies {
// ... all your dependencies here.
}
In your github project sample: you have declared the exclusion rules in the buildscript
block , which is wrong. You need to configure these exclusions outside this block (=> at the same level as repositories
or dependencies
blocks)
Note the root cause of your logging issue is that both spring-boot
and active-mq-all
dependencies provide Slf4j binding implementation in their transitive dependencies , so you need to either exclude logback
(see solution above) or the implementation from active-mq
(which seems more complicated : see https://stackoverflow.com/a/11786595/6899896 )