resteasy-cdi-获取“重复的上下文初始化参数resteasy.injector.factory"错误

resteasy-cdi-获取“重复的上下文初始化参数resteasy.injector.factory

问题描述:

我在使用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.