我们修改了与 OpenJDK 11 兼容的代码。当我们尝试通过 Tomcat 部署应用程序时,遇到以下错误:
Caused by: java.lang.IllegalAccessError: class org.slf4j.LoggerFactory tried to access private field org.slf4j.impl.StaticLoggerBinder.SINGLETON (org.slf4j.LoggerFactory and org.slf4j.impl.StaticLoggerBinder are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @61526469)
at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
at ch.qos.logback.classic.util.StatusViaSLF4JLoggerFactory.addStatus(StatusViaSLF4JLoggerFactory.java:32)
at ch.qos.logback.classic.util.StatusViaSLF4JLoggerFactory.addInfo(StatusViaSLF4JLoggerFactory.java:20)
at ch.qos.logback.classic.servlet.LogbackServletContainerInitializer.onStartup(LogbackServletContainerInitializer.java:32)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5135)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
... 38 more
pom.xml 中的依赖关系:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
</dependency>
使用 OpenJDK 8,它运行良好。
Tomcat版本:apache-tomcat-9.0.27