[英]RestEasy conflict in Jboss EAP 6.1
I am trying to use Jersey to create a RESTful API. 我正在尝试使用Jersey创建RESTful API。 My pom.xml looks like:
我的pom.xml看起来像:
<!-- 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.
但是我
Only one JAX-RS Application Class allowed.
exception while deploying the application in Jboss. 在Jboss中部署应用程序时出现异常。 However, this works very well in case of tomcat.
但是,这对于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 7上部署Jersey Webapp的答案,但到目前为止没有成功。
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
). JBoss的AS / EAP已经为您提供了JAX-RS实现(的RESTEasy),所以你的pom.xml应该只包含在JAX-RS API(示波器的依赖
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. 如果要在Tomcat和/或JBoss AS上进行构建和部署,则应使用Maven配置文件,并且仅在Tomcat配置文件中包含Jersey伪像。
JBoss不支持“开箱即用”的Jersey,它具有自己的实现RestEasy。为了使Jersey正常工作,我们要么需要在standalone.xml中禁用Jersey,然后启用ReastEasy支持。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.