gpt4 book ai didi

java - OpenWebBeans CDI 在 Java 11 中失败

转载 作者:行者123 更新时间:2023-11-30 10:08:16 31 4
gpt4 key购买 nike

我的应用程序使用 Java 11、Tomcat 9.0.13 和 OpenWeBeans CDI 2.0.8。启动 Tomcat 服务器时出现以下错误:

Dec 19, 2018 9:59:04 AM org.apache.webbeans.servlet.WebBeansConfigurationListener contextInitialized
SEVERE: An error occurred while starting application context path : [/abcServer]
Dec 19, 2018 9:59:04 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.apache.webbeans.servlet.WebBeansConfigurationListener
org.apache.webbeans.exception.WebBeansDeploymentException: java.lang.IllegalArgumentException
at org.apache.webbeans.corespi.scanner.AbstractMetaDataDiscovery.scan(AbstractMetaDataDiscovery.java:144)
at org.apache.webbeans.lifecycle.AbstractLifeCycle.bootstrapApplication(AbstractLifeCycle.java:132)
at org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(AbstractLifeCycle.java:104)
at org.apache.webbeans.web.lifecycle.WebContainerLifecycle.startApplication(WebContainerLifecycle.java:87)
at org.apache.webbeans.servlet.WebBeansConfigurationListener.contextInitialized(WebBeansConfigurationListener.java:85)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5110)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5633)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1694)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1684)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalArgumentException
at org.apache.xbean.asm5.ClassReader.<init>(Unknown Source)
at org.apache.xbean.asm5.ClassReader.<init>(Unknown Source)
at org.apache.xbean.asm5.ClassReader.<init>(Unknown Source)
at org.apache.xbean.finder.AnnotationFinder.readClassDef(AnnotationFinder.java:1169)
at org.apache.xbean.finder.AnnotationFinder.<init>(AnnotationFinder.java:147)
at org.apache.xbean.finder.AnnotationFinder.<init>(AnnotationFinder.java:160)
at org.apache.webbeans.corespi.scanner.xbean.OwbAnnotationFinder.<init>(OwbAnnotationFinder.java:37)
at org.apache.webbeans.corespi.scanner.AbstractMetaDataDiscovery.initFinder(AbstractMetaDataDiscovery.java:107)
at org.apache.webbeans.corespi.scanner.AbstractMetaDataDiscovery.scan(AbstractMetaDataDiscovery.java:140)
... 13 more

Dec 19, 2018 9:59:04 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class com.xyz.abc.application.impl.ApplicationControllerAdapter
javax.enterprise.inject.UnsatisfiedResolutionException: Api type [com.xyz.abc.cleanup.CleanupJobController] is not found with the qualifiers
Qualifiers: [@javax.enterprise.inject.Default()]
for injection into Field Injection Point, field name : cleanupJobController, Bean Owner : [null]
at org.apache.webbeans.util.InjectionExceptionUtil.throwUnsatisfiedResolutionException(InjectionExceptionUtil.java:65)
at org.apache.webbeans.container.InjectionResolver.getInjectionPointBean(InjectionResolver.java:271)
at org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:82)
at org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
at org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:220)
at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:206)
at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:196)
at com.xyz.abc.inject.CDIUtils.injectFields(CDIUtils.java:37)
at com.xyz.abc.application.impl.ApplicationStarted.<init>(ApplicationStarted.java:149)
at com.xyz.abc.application.impl.ApplicationControllerAdapter.contextInitialized(ApplicationControllerAdapter.java:34)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5110)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5633)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1694)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1684)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)

Dec 19, 2018 9:59:04 AM com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextInitialized
INFO: WSSERVLET12: JAX-WS context listener initializing
Dec 19, 2018 9:59:04 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file
Dec 19, 2018 9:59:04 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/abcServer] startup failed due to previous errors
Dec 19, 2018 9:59:04 AM com.sun.xml.ws.transport.http.servlet.WSServletDelegate destroy
INFO: WSSERVLET15: JAX-WS servlet destroyed
Dec 19, 2018 9:59:04 AM com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextDestroyed
INFO: WSSERVLET13: JAX-WS context listener destroyed
Dec 19, 2018 9:59:04 AM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class com.xyz.abc.application.impl.ApplicationControllerAdapter
javax.enterprise.inject.UnsatisfiedResolutionException: Api type [com.xyz.abc.licensing.License] is not found with the qualifiers
Qualifiers: [@javax.enterprise.inject.Default()]
for injection into Field Injection Point, field name : license, Bean Owner : [null]
at org.apache.webbeans.util.InjectionExceptionUtil.throwUnsatisfiedResolutionException(InjectionExceptionUtil.java:65)
at org.apache.webbeans.container.InjectionResolver.getInjectionPointBean(InjectionResolver.java:271)
at org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:82)
at org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
at org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:220)
at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:206)
at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:196)
at com.xyz.abc.inject.CDIUtils.injectFields(CDIUtils.java:37)
at com.xyz.abc.application.impl.ApplicationStopped.<init>(ApplicationStopped.java:85)
at com.xyz.abc.application.impl.ApplicationControllerAdapter.contextDestroyed(ApplicationControllerAdapter.java:27)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:5157)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5830)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:221)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:149)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1694)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1684)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)

请建议如何解决此问题。我已经将 Tomcat 的 opewebbeans CDI 更新到最新版本,也更新了 JaxB-api,但似乎没有任何效果。有人在 Java 11 中使用 Tomcat 9 吗?

最佳答案

TL;DR:您将 OWB 从 1.6 更新到 2.0,但未能更新他们的 dependencies .

OpenWebBeans 2.0.8 依赖于 xbean-asm7-shaded-4.12,它实现了类 org.apache.xbean.asm7.ClassReader。您的 OWB 以某种方式使用较旧的类 org.apache.xbean.asm5.ClassReader 来发现 CDI 注释的 bean 类。但是开发商in 2015未能预测 2018 年如何阅读 Java 11 类(scnr)。

稍微测试一下,我发现您的类路径中还必须有一个旧的 xbean-finder-shaded-4.3,它依赖于并使用那个旧的 org.apache.xbean.asm5.ClassReader 来自 xbean-asm5-shaded

作为结论,我建议您摆脱异常堆栈跟踪指出的那些依赖冲突。此外,您可能希望使用像 maven 这样的构建工具。这有助于在不被烧毁的情况下度过依赖 hell 。

编辑:

关于您的评论,请参阅以下问题:

根据您的环境,您可能还需要为已在 Java 9 中弃用并在 Java 11 中删除的模块添加替换:

编辑 2:

您可以@Inject DocumentBuilderFactory 实例使用带有@Produces 注释的生产者方法,如my answer to your followup question 中所述。 .

关于java - OpenWebBeans CDI 在 Java 11 中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53814919/

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