1 Reply Latest reply on Mar 18, 2013 4:25 PM by mike tihonchik

    ClassNotFoundException on com.sun.jersey.spi.container.servlet.ServletContainer

    mike tihonchik Newbie

      I am migrating project from jBoss-eap-5.1 to jboss-eap-6.0. I have defined jersey jars in the modules directory of jboss as follows (I have main folder under each of the jersey folders and module descriptor with .jar file inside that):

       

          com

          |_jersey

            |_jersey-core

            |_jersey-client

            |_jersey-server

            |_jersey-servlet

       

      In my project .pom file i defined the jars as follows:

       

          <dependency>

              <groupId>com.sun.jersey</groupId>

              <artifactId>jersey-servlet</artifactId>

              <version>1.10</version>

              <scope>provided</scope>

          </dependency>

          <dependency>

              <groupId>com.sun.jersey</groupId>

              <artifactId>jersey-core</artifactId>

              <version>${jersey-version}</version>

              <scope>provided</scope>

          </dependency>

          <dependency>

              <groupId>com.sun.jersey</groupId>

              <artifactId>jersey-client</artifactId>

              <version>${jersey-version}</version>

              <scope>test</scope>

          </dependency>

       

      However, when I try to deploy, I get the following error on ServletContainer class:

       

          13:03:29,908 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC000001: Failed to start service jboss.deployment.subunit."ApiEar-2.0.0-SNAPSHOT.ear"."ApiService-2.

          0.0-SNAPSHOT.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."ApiEar-2.0.0-SNAPSHOT.ear"."ApiService-2.0.0-SNAPSHOT.war".POST_MODULE

          : JBAS018733: Failed to process phase POST_MODULE of subdeployment "ApiService-2.0.0-SNAPSHOT.war" of deployment "ApiEar-2.0.0-SNAPSHOT.ear"

                  at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:123) [jboss-as-server-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

       

                  at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA-redhat-1.jar:1.0.2.GA-redhat-1]

                  at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA-redhat-1.jar:1.0.2.GA-redhat-1]

                  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_32-ea]

                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_32-ea]

                  at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_32-ea]

          Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer from [Modu

          le "deployment.ApiEar-2.0.0-SNAPSHOT.ear.ApiService-2.0.0-SNAPSHOT.war:main" from Service Module Loader]

                  at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.checkDeclaredApplicationClassAsServlet(JaxrsScanningProcessor.java:295)

                  at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.scanWebDeployment(JaxrsScanningProcessor.java:160)

                  at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.deploy(JaxrsScanningProcessor.java:109)

                  at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:116) [jboss-as-server-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

       

                  ... 5 more

       

      Initially, I was getting this error when I did not define jersey-servlet, but I did some searching, and presumably, jersey-servlet.jar is the one that contains that class. However, that did solve the error.

      thank you

        • 1. Re: ClassNotFoundException on com.sun.jersey.spi.container.servlet.ServletContainer
          mike tihonchik Newbie

          I fixed this error by bumping jersey version to 1.17 and adding jersey-servlet maven dependency. So no, my .pom file looks like this:

           

                  <dependency>

                      <groupId>com.sun.jersey</groupId>

                      <artifactId>jersey-server</artifactId>

                      <version>${jersey-version}</version>

                      <scope>compile</scope>

                  </dependency>

                  <dependency>

                      <groupId>com.sun.jersey</groupId>

                      <artifactId>jersey-json</artifactId>

                      <version>${jersey-version}</version>

                      <scope>compile</scope>

                  </dependency>

                  <dependency>

                      <groupId>com.sun.jersey</groupId>

                      <artifactId>jersey-client</artifactId>

                      <version>${jersey-version}</version>

                      <scope>compile</scope>

                  </dependency>

           

                  <!-- Jersey 1.17 dependencies -->

                  <dependency>

                      <groupId>com.sun.jersey</groupId>

                      <artifactId>jersey-servlet</artifactId>

                      <version>${jersey-version}</version>

                      <scope>compile</scope>

                  </dependency>

                  <!-- end Jersey 1.17 dependencies -->