title: Failed to start service jboss.deployment.unit."RSSample.war".POST_MODULE:
body: <p>I want to deploy a jersey restful webservice that produces JSON.. but i get the following error </p>
  
  <blockquote>
    <p>14:08:26,743 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-9) MSC00001: Failed to start service jboss.deployment.unit."RSSample.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."RSSample.war".POST_MODULE: Failed to process phase POST_MODULE of deployment "RSSample.war"
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_79]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_79]
        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_79]
    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011232: Only one JAX-RS Application Class allowed.  org.glassfish.jersey.server.ResourceConfig org.glassfish.jersey.server.ResourceConfig$WrappingResourceConfig org.glassfish.jersey.server.ResourceConfig$RuntimeConfig
        at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.scan(JaxrsScanningProcessor.java:209)
        at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.deploy(JaxrsScanningProcessor.java:105)
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
        ... 5 more</p>
  </blockquote>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!-- This web.xml file is not required when using Servlet 3.0 container,
      see implementation details &gt;http://jersey.java.net/nonav/documentation/latest/jax-rs.html --&gt; &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
  &gt;xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" &gt;xsi:schemaLocation="http://java.sun.com/xml/ns/javaee &gt;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;    &lt;servlet&gt;
         &lt;servlet-name&gt;Jersey Web Application&lt;/servlet-name&gt;
         &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-&gt;class&gt;
         &lt;init-param&gt;
             &lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;
             &lt;param-value&gt;com.ph.restful.sample.RSSample&lt;/param-value&gt;
         &lt;/init-param&gt;
         &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;    &lt;/servlet&gt;    &lt;servlet-mapping&gt;
         &lt;servlet-name&gt;Jersey Web Application&lt;/servlet-name&gt;
         &lt;url-pattern&gt;/webapi/*&lt;/url-pattern&gt;    &lt;/servlet-mapping&gt; &lt;/web-app&gt;
  </code></pre>
  
  <p>My pom.xml</p>
  
  <pre><code>&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
  &lt;groupId&gt;com.ph.restful.sample&lt;/groupId&gt;
  &lt;artifactId&gt;RSSample&lt;/artifactId&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;RSSample&lt;/name&gt;
  
  &lt;build&gt;
      &lt;finalName&gt;RSSample&lt;/finalName&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.5.1&lt;/version&gt;
              &lt;inherited&gt;true&lt;/inherited&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.7&lt;/source&gt;
                  &lt;target&gt;1.7&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  
  &lt;dependencyManagement&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-bom&lt;/artifactId&gt;
              &lt;version&gt;${jersey.version}&lt;/version&gt;
              &lt;type&gt;pom&lt;/type&gt;
              &lt;scope&gt;import&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/dependencyManagement&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-container-servlet-core&lt;/artifactId&gt;
          &lt;!-- use the following artifactId if you don't need servlet 2.x compatibility --&gt;
          &lt;!-- artifactId&gt;jersey-container-servlet&lt;/artifactId --&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-media-moxy&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  &lt;properties&gt;
      &lt;jersey.version&gt;2.22.2&lt;/jersey.version&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
  &lt;/properties&gt;
  </code></pre>
  
  <p></p>
  
  <p>MyResource.java</p>
  
  <pre><code>@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;
  }
  </code></pre>
  
  <p>Product.java</p>
  
  <pre><code>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;
  }
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/TkJdv.png" rel="nofollow">This is the project structure</a></p>
  
  <p>jboss-deployment-structure.xml</p>
  
  <pre><code> &lt;jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"&gt;
    &lt;deployment&gt;
       &lt;exclude-subsystems&gt;
          &lt;subsystem name="jaxrs" /&gt;
      &lt;/exclude-subsystems&gt;      
       &lt;exclusions&gt;  
        &lt;module name="javax.ws.rs.api" /&gt;  
      &lt;/exclusions&gt;  
    &lt;deployment&gt;
    &lt;/jboss-deployment-structure&gt;
  </code></pre>