resteasy-cdi - 获取“重复上下文初始化参数 resteasy.injector.factory";错误 [英] resteasy-cdi - getting "Duplicate context initialization parameter resteasy.injector.factory" error
问题描述
我在使用 RESTEASY 的其余应用程序上需要 CDI 功能.所以我遵循了手册的说明 在我的应用程序上设置 resteasy-cdi 模块,该模块在 JBoss AS7 上运行.
I'm needing CDI functionality on a rest application in which I'm using RESTEASY. So I followed the manual's instruction to setup resteasy-cdi module on my app, that runs on JBoss AS7.
但是当我启动服务器时出现以下错误:
But when I start the server I get the following error:
13:48:08,631 错误 [org.apache.catalina.core.StandardContext](MSC 服务线程 1-4)上下文 [/MainService] 启动失败,因为以前的错误:java.lang.IllegalArgumentException:重复上下文初始化参数 resteasy.injector.factory
13:48:08,631 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-4) Context [/MainService] startup failed due to previous errors: java.lang.IllegalArgumentException: Duplicate context initialization parameter resteasy.injector.factory
我的 web.xml 如下:
My web.xml is the following:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<context-param>
<param-name>resteasy.injector.factory</param-name>
<param-value>org.jboss.resteasy.cdi.CdiInjectorFactory</param-value>
</context-param>
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
我尝试了几种参数组合,并尝试像 这个线程 也是,但没有成功.
I've tried several combinations of parameters, and tried to configure it like in this thread also, but without success.
在 web.xml 上指定 javax.ws.rs.core.Application 并禁用 resteasy.scan 也没有解决问题.
Specifying the javax.ws.rs.core.Application on the web.xml and desabling the resteasy.scan also didn't solve the problem.
我的 pom.xml 有以下内容:
My pom.xml has the following content:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-cdi</artifactId>
<version>2.2.1.GA</version>
</dependency>
我还尝试在使用和不使用工件 resteasy-jarxs 以及依赖声明(如 这篇文章.
I've also tried testing with and without the artifact resteasy-jarxs together and with the declaration of the dependency like this article.
我真的迷路了.你有什么想法?我现在需要 CDI 或 EJB 才能通过注入使用 JPA 的 EntityManager.我知道没有它我也可以使用,但我更愿意这样我可以在未来探索 JTA 的集成和 CDI 的功能.
I'm really lost. Do you have any ideas? I need CDI or EJB for now to use JPA's EntityManager via injection. I know that I can use without it, but I'd prefer to so I can explore JTA's integration and CDI's functionality on the future.
谢谢.
推荐答案
我遇到了同样的错误,尝试了 RestEasy jar 版本和包含/排除,但没有取得任何进展.所以我在 RestEasy JBoss 问题跟踪器( https://issues.jboss.org/browse/RESTEASY-586 ),我希望最终能得到答复.我也在使用 JBoss AS 7 和最新的 RestEasy、CDI 和 Seam.
I hit this same error, experimented with RestEasy jar versions and inclusion/exclusion, and made no progress solving it. So I reported a bug at the RestEasy JBoss issue tracker ( https://issues.jboss.org/browse/RESTEASY-586 ) that I hope will get a reply eventually. I'm also using JBoss AS 7 and the latest RestEasy and CDI and Seam.
我的应用程序在 Glassfish 3.1.1 中运行良好,但当我将其移至 JBoss AS 7 时出现故障(出现重复上下文初始化参数 resteasy.injector.factory"错误).
My application worked fine in Glassfish 3.1.1 but broke (with this "Duplicate context initialization parameter resteasy.injector.factory" error) when I moved it to JBoss AS 7.
这篇关于resteasy-cdi - 获取“重复上下文初始化参数 resteasy.injector.factory";错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!