gpt4 book ai didi

java - 无法将 infinispan 升级到 9.1.0.Final : ClassCastException

转载 作者:行者123 更新时间:2023-11-28 22:25:49 25 4
gpt4 key购买 nike

我正在尝试将 infinispan 从 8.2.4.Final 升级到 9.1.0.Final,但是在构建 tomcat war 文件时从嵌入式 slf4j 中得到了一些错误。

日志:

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 anexplanation.

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.configureLoggingExternalLoading logger configuration from C:\my-files\conf\logback.xml

java.lang.ClassCastException: org.jboss.slf4j.JBossLoggerFactorycannot be cast to ch.qos.logback.classic.LoggerContext

日志中提到的代码:

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);
}

错行在这里:final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();

首先,我从“infinispan-embedded”依赖项中排除了 slf4j-api,但没有成功,因为 slf4j 是硬编码的。

其次,我添加了<packagingExcludes>WEB-INF/lib/infinispan-embedded-9.1.0.Final.jar!/org/slf4j/impl/StaticLoggerBinder.class</packagingExcludes>到 maven-war-plugin(也许带有'!'符号我们无法访问嵌套的 jar ,但我没有找到其他变体)。尝试失败。

那么,我该如何解决这个异常呢?也许可以使用 maven-shade-plugin?但这对我的项目来说似乎是 Not Acceptable 。

最佳答案

我有一些问题。我用一个技巧来解决它。我从依赖项中排除了 logback。我使用 infinispan-embedded 作为记录器。但我认为这不是解决问题的正确方法。我认为“http://infinispan.org/”开发人员需要将有关记录器的代码导出为另一个 jar。然后我们可以在maven中排除。实际上,由于另一个任务而依赖 logger jar 是不正确的。

关于java - 无法将 infinispan 升级到 9.1.0.Final : ClassCastException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45266622/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com