gpt4 book ai didi

java - Tomcat 7 上的 RESTEasy CDI 部署异常

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

我正在尝试使用 RESTEasy 3.0.6 在 Tomcat 7.0 上部署 Web 应用程序以获得 RESTful 服务支持。但是,当我尝试部署应用程序时,出现以下异常:

2014-04-09 11:25:27 DEBUG CdiInjectorFactory:68 - Doing a lookup for BeanManager in java:comp/BeanManager
2014-04-09 11:25:27 DEBUG CdiInjectorFactory:68 - Unable to obtain BeanManager from java:comp/BeanManager
2014-04-09 11:25:27 DEBUG CdiInjectorFactory:68 - Doing a lookup for BeanManager in java:app/BeanManager
2014-04-09 11:25:27 DEBUG CdiInjectorFactory:68 - Unable to obtain BeanManager from java:app/BeanManager
2014-04-09 11:25:27 DEBUG CdiInjectorFactory:75 - Not able to access CDI Object, class not found.
java.lang.ClassNotFoundException: javax.enterprise.inject.spi.CDI
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at org.jboss.resteasy.cdi.CdiInjectorFactory.lookupBeanManagerCDIUtil(CdiInjectorFactory.java:201)
at org.jboss.resteasy.cdi.CdiInjectorFactory.lookupBeanManager(CdiInjectorFactory.java:167)
at org.jboss.resteasy.cdi.CdiInjectorFactory.<init>(CdiInjectorFactory.java:42)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.lang.Class.newInstance(Class.java:374)
at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:148)
at org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap.contextInitialized(ResteasyBootstrap.java:28)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Apr 09, 2014 11:25:27 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
java.lang.RuntimeException: Unable to instantiate InjectorFactory implementation.
at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:156)
at org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap.contextInitialized(ResteasyBootstrap.java:28)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.RuntimeException: Unable to lookup BeanManager.
at org.jboss.resteasy.cdi.CdiInjectorFactory.lookupBeanManager(CdiInjectorFactory.java:174)
at org.jboss.resteasy.cdi.CdiInjectorFactory.<init>(CdiInjectorFactory.java:42)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.lang.Class.newInstance(Class.java:374)
at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:148)
... 10 more

我关注了the instructions关于如何将 RESTEasy-CDI 合并到我的 Maven 构建中,我看到 WAR 正在正确构建。但是,我在部署时仍然看到异常。

我的 web.xml 文件的相关部分如下所示:

  <listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
<filter>
<filter-name>ConversationPropagationFilter</filter-name>
<filter-class>org.jboss.weld.servlet.ConversationPropagationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ConversationPropagationFilter</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>

<resource-env-ref>
<description>Object factory for the CDI Bean Manager</description>
<resource-env-ref-name>BeanManager</resource-env-ref-name>
<resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
</resource-env-ref>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.myapp.web.rest.JaxRsActivator</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/rest</param-value>
</context-param>

知道可能导致此错误的原因或如何解决此错误吗?在这一点上,它基本上是一个表演终结者。

最佳答案

发现问题。这只是一个 servlet 监听器排序问题。我在初始化 CDI 之前初始化 RESTEasy。

关于java - Tomcat 7 上的 RESTEasy CDI 部署异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22967263/

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