无法启动服务 jboss.deployment.unit。“RSSample.war”.POST_MODULE:
Posted
技术标签:
【中文标题】无法启动服务 jboss.deployment.unit。“RSSample.war”.POST_MODULE:【英文标题】:Failed to start service jboss.deployment.unit."RSSample.war".POST_MODULE: 【发布时间】:2016-06-14 21:23:02 【问题描述】:我想部署一个生成 JSON 的 jersey restful webservice.. 但我收到以下错误
14:08:26,743 错误 [org.jboss.msc.service.fail](MSC 服务线程 1-9)MSC00001:无法启动服务 jboss.deployment.unit。“RSSample.war”.POST_MODULE: org.服务 jboss.deployment.unit."RSSample.war".POST_MODULE 中的 jboss.msc.service.StartException:无法处理部署“RSSample.war”的阶段 POST_MODULE 在 org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final] 在 org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA] 在 org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA] 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_79] 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_79] 在 java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_79] 原因:org.jboss.as.server.deployment.DeploymentUnitProcessingException:JBAS011232:只允许一个 JAX-RS 应用程序类。 org.glassfish.jersey.server.ResourceConfig org.glassfish.jersey.server.ResourceConfig$WrappingResourceConfig org.glassfish.jersey.server.ResourceConfig$RuntimeConfig 在 org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.scan(JaxrsScanningProcessor.java:209) 在 org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.deploy(JaxrsScanningProcessor.java:105) 在 org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final] ... 5 更多
web.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- This web.xml file is not required when using Servlet 3.0 container,
see implementation details >http://jersey.java.net/nonav/documentation/latest/jax-rs.html --> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >xsi:schemaLocation="http://java.sun.com/xml/ns/javaee >http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet->class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.ph.restful.sample.RSSample</param-value>
</init-param>
<load-on-startup>1</load-on-startup> </servlet> <servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/webapi/*</url-pattern> </servlet-mapping> </web-app>
我的 pom.xml
<modelVersion>4.0.0</modelVersion>
<groupId>com.ph.restful.sample</groupId>
<artifactId>RSSample</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>RSSample</name>
<build>
<finalName>RSSample</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>$jersey.version</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency>
</dependencies>
<properties>
<jersey.version>2.22.2</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
MyResource.java
@GET
@Path("/get")
@Produces("application/json")
public Product getIt()
Product prod = new Product();
prod.setName("PS4");
prod.setId("123");
prod.setDescription("console game");
return prod;
Product.java
private String name;
private String id;
private String description;
public String getName()
return name;
public void setName(String name)
this.name = name;
public String getId()
return id;
public void setId(String id)
this.id = id;
public String getDescription()
return description;
public void setDescription(String description)
this.description = description;
This is the project structure
jboss-deployment-structure.xml
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclude-subsystems>
<subsystem name="jaxrs" />
</exclude-subsystems>
<exclusions>
<module name="javax.ws.rs.api" />
</exclusions>
<deployment>
</jboss-deployment-structure>
【问题讨论】:
【参考方案1】:Here the problem is with multiple rest service implementations i.e., one is jboss rest implementation and another one is jersey.So here in this case , you may have to exclude the jaxrs of jboss by creating jboss-deployment-structure.xml file and excluding that.
Example of jboss-deployment-structure.xml
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<dependencies>
<module name="org.jboss.as.jpa"/>
<module name="org.hibernate"/>
</dependencies>
<exclude-subsystems>
<subsystem name="jaxrs" />
</exclude-subsystems>
<exclusions>
<!-- <module name="org.jboss.as.jsf"/> -->
<module name="org.jboss.as.jaxrs"/>
<module name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider"/>
<module name="com.fasterxml.jackson.core.jackson-annotations"/>
<module name="com.fasterxml.jackson.core.jackson-databind"/>
<module name="com.fasterxml.jackson.core.jackson-core"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
【讨论】:
我在哪里可以在 jboss 上添加文件?什么路径?对不起这里的初学者:) 我需要什么依赖? 如果您的应用程序有 RSSampleEAR 项目,请将此文件放在 RSSampleEAR/META-INF 中,或者如果只是战争,请将文件放在 WEB-INF 文件夹中。如上所示,您需要排除 jaxrs .您可以使用相同的xml,它工作正常。如果有任何问题,请在此处评论。 嗨,谢谢..我编辑了我的帖子并包含了我的项目结构截图..它是一个我想要部署的 .WAR 文件..你能提供我可以写在我的 jboss 上的确切值吗-部署结构.xml?我还包括 mt jboss-deployment-structure.xml 嗨,你能在你的本地 jboss 环境中像下面这样评论该行并尝试@wildfly-8.2.0.Final\modules\system\layers\base\javax\ws\rs\api\main \module.xml 注释行以上是关于无法启动服务 jboss.deployment.unit。“RSSample.war”.POST_MODULE:的主要内容,如果未能解决你的问题,请参考以下文章