I am trying to upgrade infinispan from 8.2.4.Final to 9.1.0.Final, but get some errors from embedded slf4j while building tomcat war-file.
Logs:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/tomcat/webapps/ROOT/WEB-INF/lib/infinispan-embedded-9.1.0.Final.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/tomcat/webapps/ROOT/WEB-INF/lib/logback-classic-1.1.6.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.jboss.slf4j.JBossLoggerFactory] 20-Jul-2017 16:07:34.170
ERROR [RMI TCP Connection(5)-127.0.0.1] com.myapp.context.LogbackLoggingConfigurator.configureLoggingExternal Loading logger configuration from C:\my-files\conf\logback.xml
java.lang.ClassCastException: org.jboss.slf4j.JBossLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext
The code, mentioned in logs:
public void configureLogging(final URL config) {
final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
try {
lc.reset();
final JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
configurator.doConfigure(config);
} catch (final JoranException je) {
logger.error("Unable to configure logback", je);
}
StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
}
And wrong line is here: final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
Firstly, I excluded slf4j-api from "infinispan-embedded" dependency, but unsuccessfully because slf4j is hardcoded.
Secondly, I added <packagingExcludes>WEB-INF/lib/infinispan-embedded-9.1.0.Final.jar!/org/slf4j/impl/StaticLoggerBinder.class</packagingExcludes>
to maven-war-plugin (maybe with '!' symbol we cannot get access to nested jars, but I don't find another variants). Attempt was failed.
So, how can I fix this exception? Maybe it is possible to use maven-shade-plugin? But it seems unacceptable for my project.