[英]Can not upgrade infinispan to 9.1.0.Final: ClassCastException
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. 我正在尝试将infinispan从8.2.4.Final升级到9.1.0.Final,但是在构建tomcat war-file时,嵌入式slf4j出现了一些错误。
Logs: 日志:
SLF4J: Class path contains multiple SLF4J bindings. SLF4J:类路径包含多个SLF4J绑定。
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:在[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:在[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:有关说明,请参见http://www.slf4j.org/codes.html#multiple_bindings 。
SLF4J: Actual binding is of type [org.jboss.slf4j.JBossLoggerFactory] 20-Jul-2017 16:07:34.170 SLF4J:实际绑定的类型为[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 错误[RMI TCP连接(5)-127.0.0.1] com.myapp.context.LogbackLoggingConfigurator.configureLoggingExternal从C:\\ my-files \\ conf \\ logback.xml加载记录器配置
java.lang.ClassCastException : org.jboss.slf4j.JBossLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext java.lang.ClassCastException :org.jboss.slf4j.JBossLoggerFactory无法转换为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();
错误的行在这里: final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
Firstly, I excluded slf4j-api from "infinispan-embedded" dependency, but unsuccessfully because slf4j is hardcoded. 首先,我从“ infinispan-embedded”依赖中排除了slf4j-api,但未成功,因为slf4j是硬编码的。
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). 其次,我在<packagingExcludes>WEB-INF/lib/infinispan-embedded-9.1.0.Final.jar!/org/slf4j/impl/StaticLoggerBinder.class</packagingExcludes>
maven-war-plugin <packagingExcludes>WEB-INF/lib/infinispan-embedded-9.1.0.Final.jar!/org/slf4j/impl/StaticLoggerBinder.class</packagingExcludes>
添加了<packagingExcludes>WEB-INF/lib/infinispan-embedded-9.1.0.Final.jar!/org/slf4j/impl/StaticLoggerBinder.class</packagingExcludes>
(可能带有'! '符号,表示我们无法访问嵌套的jar,但找不到其他变体)。 Attempt was failed. 尝试失败。
So, how can I fix this exception? 那么,如何解决此异常? Maybe it is possible to use maven-shade-plugin? 也许可以使用maven-shade-plugin? But it seems unacceptable for my project. 但这对于我的项目来说似乎是无法接受的。
I have some problem. 我有问题 I solve it with a trick. 我用技巧解决了。 I exclude logback from dependencies. 我从依赖项中排除了logback。 I used infinispan-embedded as logger. 我使用infinispan嵌入式作为记录器。 But I think it is not right way to solve the problem. 但是我认为这不是解决问题的正确方法。 I think " http://infinispan.org/ " developers need to export codes about logger as another jar. 我认为“ http://infinispan.org/ ”开发人员需要将有关logger的代码导出为另一个jar。 Then we can exclude in maven. 然后我们可以排除在Maven中。 Actually It is not right way to be dependent logger jar because of another task. 实际上,由于另一个任务,依赖记录器jar是不正确的方法。
I have some problem. 我有问题 I solve it with a trick. 我用技巧解决了。 I exclude logback from dependencies. 我从依赖项中排除了logback。 I used infinispan-embedded as logger. 我使用infinispan嵌入式作为记录器。 But I think it is not right way to solve the problem. 但是我认为这不是解决问题的正确方法。 I think " http://infinispan.org/ " developers need to export codes about logger as another jar. 我认为“ http://infinispan.org/ ”开发人员需要将有关logger的代码导出为另一个jar。 Then we can exclude in maven. 然后我们可以排除在Maven中。 Actually It is not right way to be dependent logger jar because of another task. 实际上,由于另一个任务,依赖记录器jar是不正确的方法。
I wrote to infinispan team and they quick respond. 我写信给infinispan团队,他们很快做出了回应。 As they said infinispan-embedded is "uber-jar" it is mean "all dependencies in one". 正如他们所说的infinispan-embedded是“超级jar”一样,它的意思是“所有依赖关系都在一个之中”。 You can use each dependencies of infinispan instead of it. 您可以使用infinispan的每个依赖项代替它。 infinispan-core and which you want to use. infinispan-core和您要使用的。
You can see detail of the opened issue by clicking on this link https://developer.jboss.org/message/975209?et=watches.email.thread#975209 on jboss website. 您可以通过在jboss网站上单击以下链接https://developer.jboss.org/message/975209?et=watches.email.thread#975209来查看已解决问题的详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.