当前位置: 首页 > 知识库问答 >
问题:

开启服务失败jboss.deployment.unit."RSSample.war"。POST_MODULE:

都沈浪
2023-03-14

我想部署一个生成JSON的jersey restful Web服务。。但是我得到了以下错误

14:08:26743错误[org.jboss.msc.service.fail](msc服务线程1-9)MSC00001:无法启动服务jboss.deployment.unit.“RSSample.war”。POST_模块:org.jboss.msc.service.StartException in service jboss.deployment.unit.“RSSample.war”。POST_模块:无法处理部署“RSSample.war”的阶段POST_模块在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.msc.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(Thread.java:745)[.jar:1.7.0_79]原因:org.jboss.as.server.deployment.DeploymentUnitProcessingException:JBAS011232:只允许一个JAX-RS应用程序类。org.glassfish.jersey.server.ResourceConfig org.glassfish.jersey.server.ResourceConfig$RuntimeConfig位于org.jboss.as.jaxrs.deployment.jaxrscanningprocessor.scan(jaxrscanningprocessor.java:209)位于org.jboss.as.jaxrs.deployment.jaxrscanningprocessor.deploy(jaxrscanningprocessor.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;
}

这是项目结构

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个答案

邢硕
2023-03-14
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>
 类似资料:
  • 我想部署一个生成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.MSC.service.startService

  • 而且我也无法在windows serice中启动neo4j服务。也许以前有人遇到过这个案子?

  • 我在自动加载tomcat7时遇到问题。这是init。d脚本: 这样开始时: Tomcat似乎无法从apache公共资源加载属性文件。有人知道这是为什么吗? 直接运行时一切正常,如下所示: 运行通过: %% 现在,我加载了导致错误的网页

  • 启动jboss服务器时,出现错误,无法启动服务jboss.deployment.unit.“jbpm console.war”。但是当我使用start.demo运行jbpm6演示时,它工作得很好。

  • 我正在使用Vagrant部署到Ubuntu Linux,并尝试启动服务。 然后我跟踪,发现: ?tomcat8.service-lsb:启动tomcat。加载:加载(/etc/init.d/tomcat8) active:失败(结果:exit-code)自2016-03-28 09:44:17 GMT;5s前 文档:人:systemd-sysv-generator(8) 进程:884 execst

  • 尝试远程启动服务时遇到奇怪的行为。 编辑:我进一步研究了这个问题,发现只有在尝试运行我的特定服务时才会出现这种情况。这意味着我的服务必须从已经登录的用户的会话中运行(这就是为什么如果我之前使用mstsc访问服务器,它仍然可以工作)。所以我想我的新问题是--有没有一种方法可以让我从PowerShell登录到远程机器? 多谢了。