简体   繁体   中英

RestEasy conflict in Jboss EAP 6.1

I am trying to use Jersey to create a RESTful API. My pom.xml looks like:

<!-- Jersey Library -->
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.18</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-bundle</artifactId>
            <version>1.18</version>
        </dependency>
        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm</artifactId>
            <version>3.3.1</version>
        </dependency>

But I get Only one JAX-RS Application Class allowed. exception while deploying the application in Jboss. However, this works very well in case of tomcat.

Stacktrace:

ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."apiinterface.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."apiinterface.war".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment "apiinterface.war"
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:127) [jboss-as-server-7.2.0.Final-redhat-4.jar:7.2.0.Final-redhat-4]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45]
        at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011232: Only one JAX-RS Application Class allowed.  com.sun.jersey.api.core.ClasspathResourceConfig com.sun.jersey.api.core.DefaultResourceConfig com.sun.jersey.server.impl.application.DeferredResourceConfig com.sun.jersey.api.core.servlet.WebAppResourceConfig com.sun.jersey.api.core.DefaultResourceConfig com.sun.jersey.api.core.ApplicationAdapter com.sun.jersey.api.core.ClassNamesResourceConfig com.sun.jersey.api.core.ResourceConfig com.sun.jersey.api.core.ApplicationAdapter com.sun.jersey.api.core.ClasspathResourceConfig com.sun.jersey.server.impl.application.DeferredResourceConfig com.sun.jersey.api.core.ScanningResourceConfig com.sun.jersey.api.core.ScanningResourceConfig com.sun.jersey.api.core.PackagesResourceConfig com.sun.jersey.api.core.ClassNamesResourceConfig com.sun.jersey.api.core.PackagesResourceConfig com.sun.jersey.api.core.ResourceConfig
        at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.scan(JaxrsScanningProcessor.java:206)
        at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.deploy(JaxrsScanningProcessor.java:104)
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:120) [jboss-as-server-7.2.0.Final-redhat-4.jar:7.2.0.Final-redhat-4]
        ... 5 more

I tried implementing answers from Deploying a Jersey webapp on Jboss AS 7 but no success so far.

JBoss AS / EAP already provides you with a JAX-RS implementation (RESTEasy), so your pom.xml should only contain a dependency on the JAX-RS API (with scope provided ).

If you want to build and deploy on Tomcat and/or JBoss AS, you should use Maven profiles and include Jersey artefacts in the Tomcat profile only.

JBoss不支持“开箱即用”的Jersey,它具有自己的实现RestEasy。为了使Jersey正常工作,我们要么需要在standalone.xml中禁用Jersey,然后启用ReastEasy支持。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM