Tomcat 8.5.37 无法在 Eclipse 中使用 AdoptOpenJDK 的 Open JDK 8.u192 运行应用程序

Tomcat 8.5.37 无法在 Eclipse 中使用 AdoptOpenJDK 的 Open JDK 8.u192 运行应用程序

我之前使用的是 Oracle JDK,但为了避免许可证问题,我迁移到了 OpenJDK。我选择了 Windows AdoptOpenJdk 8_192,但在 Eclipse 中使用 Tomcat 8.5 运行它时遇到了一些问题(这种情况仅在使用 Tomcat 运行时才会发生,桌面 Java 应用程序可以正常运行)。

Tomcat控制台输出如下:

    com.google.common.util.concurrent.ExecutionError: java.lang.IncompatibleClassChangeError
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2256)
    at com.google.common.cache.LocalCache.get(LocalCache.java:3990)
    at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3994)
    at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4878)
    at org.jboss.weld.util.cache.LoadingCacheUtils.getCacheValue(LoadingCacheUtils.java:49)
    at org.jboss.weld.util.cache.LoadingCacheUtils.getCastCacheValue(LoadingCacheUtils.java:74)
    at org.jboss.weld.bean.proxy.ClientProxyProvider.getClientProxy(ClientProxyProvider.java:204)
    at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:736)
    at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:762)
    at org.jboss.weld.util.ForwardingBeanManager.getReference(ForwardingBeanManager.java:61)
    at org.jboss.weld.bean.builtin.BeanManagerProxy.getReference(BeanManagerProxy.java:89)
    at org.omnifaces.util.BeansLocal.getReference(BeansLocal.java:104)
    at org.omnifaces.util.BeansLocal.getReference(BeansLocal.java:92)
    at org.omnifaces.util.Beans.getReference(Beans.java:115)
    at org.omnifaces.cdi.eager.EagerBeansRepository.getInstance(EagerBeansRepository.java:66)
    at org.omnifaces.cdi.eager.EagerBeansRepository.instantiateApplicationScopedAndRegisterListenerIfNecessary(EagerBeansRepository.java:78)
    at org.omnifaces.ApplicationListener.contextInitialized(ApplicationListener.java:83)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:813)
Caused by: java.lang.IncompatibleClassChangeError
    at java.security.AccessController.doPrivileged(AccessController.java:647)
    at org.omnifaces.cdi.eager.EagerBeansRepository$Proxy$_$$_WeldClientProxy.<clinit>(Unknown Source)
    at java.lang.J9VMInternals.newInstanceImpl(Native Method)
    at java.lang.Class.newInstance(Class.java:1847)
    at org.jboss.weld.security.NewInstanceAction.run(NewInstanceAction.java:33)
    at java.security.AccessController.doPrivileged(AccessController.java:703)
    at org.jboss.weld.bean.proxy.ProxyFactory.create(ProxyFactory.java:303)
    at org.jboss.weld.bean.proxy.ClientProxyFactory.create(ClientProxyFactory.java:111)
    at org.jboss.weld.bean.proxy.ClientProxyProvider.createClientProxy(ClientProxyProvider.java:180)
    at org.jboss.weld.bean.proxy.ClientProxyProvider.createClientProxy(ClientProxyProvider.java:170)
    at org.jboss.weld.bean.proxy.ClientProxyProvider.access$100(ClientProxyProvider.java:45)
    at org.jboss.weld.bean.proxy.ClientProxyProvider$CreateClientProxy.load(ClientProxyProvider.java:56)
    at org.jboss.weld.bean.proxy.ClientProxyProvider$CreateClientProxy.load(ClientProxyProvider.java:52)
    at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3589)
    at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2374)
    at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2337)
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2252)
    ... 25 more

我想知道如何解决这个问题。提前谢谢。

答案1

这并不是我的问题的正确答案,但它解决了问题:之前我使用的是 AdoptOpenJDK 的 OpenJDK 和 OpenJ9 JVM,所以我改用了 Hotspot 版本并且它起作用了。

Tomcat 8 和 OpenJ9 JVM 之间可能存在一些不兼容性。

相关内容