1 Reply Latest reply on Aug 14, 2015 1:04 AM by Ragav Baskaran

    Jersey 2.19 - JBoss EAP 6.2 - JBWEB000260: No servlet class has been specified for servlet

    Ragav Baskaran Newbie

      I'm trying to deploy a simple restful service in JBoss EAP 6.2 with Jersey 2.19.

       

      Subclass of Application class:

       

      package com.jersey.mywebapp;

      import javax.ws.rs.ApplicationPath;

      import javax.ws.rs.core.Application;

      import java.util.HashSet;

      import java.util.Set;

       

      @ApplicationPath("resources")

      public class MyApp extends Application {

          public Set<Class<?>> getClasses() {

              Set<Class<?>> s = new HashSet<Class<?>>();

              s.add(MyResource.class);

              return s;

          }

      }

       

      RS Implementation class:

       

      package com.jersey.mywebapp;

      import javax.ws.rs.GET;

      import javax.ws.rs.Path;

      import javax.ws.rs.Produces;

      import javax.ws.rs.core.MediaType;

      @Path("myresource")

      public class MyResource {

          @GET

          @Produces(MediaType.TEXT_PLAIN)

          public String getIt() {

              return "Got it!";

          }

      }

       

      My deployment descriptor:

      ..

          <servlet>

              <display-name>My JAX-RS Servlet</display-name>

              <servlet-name>com.jersey.mywebapp.MyApp</servlet-name>

              <init-param>

                  <param-name>javax.ws.rs.Application</param-name>

                  <param-value>com.jersey.mywebapp.MyApp</param-value>

              </init-param>

          </servlet>

          <servlet-mapping>

              <servlet-name>com.jersey.mywebapp.MyApp</servlet-name>

              <url-pattern>/resources/*</url-pattern>

          </servlet-mapping>

      ...

       

      Getting the below error while accessing the resource (localhost:8080/{context}/resources/myresource

       

      21:51:29,437 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/rpa]] (http-/127.0.0.1:8080-1) JBWEB000264: Marking servlet com.jersey.mywebapp.MyApp as unavailable

      21:51:29,446 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/rpa].[com.jersey.mywebapp.MyApp]] (http-/127.0.0.1:8080-1) JBWEB000235: Allocate exception for servlet com.

      jersey.mywebapp.MyApp: javax.servlet.ServletException: JBWEB000260: No servlet class has been specified for servlet com.jersey.mywebapp.MyApp

              at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1147) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

              at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:950) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:151) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

              at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

              at java.lang.Thread.run(Thread.java:780) [vm.jar:1.7.0]

       

      As per my understanding JBoss EAP 6.2 supports Servlet 3.0 and as per Jersey documentation (Chapter 4. Application Deployment and Runtime Environments), Its valid to omit the servlet-class as per servlet pluggability mechanism.

       

      Please advise on how to resolve this problem?

       

      Note: To avoid/suppress RESTEasy from scanning for JAX RS resources i have commented out - <subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/> from standalone.xml

        • 1. Re: Jersey 2.19 - JBoss EAP 6.2 - JBWEB000260: No servlet class has been specified for servlet
          Ragav Baskaran Newbie

          Able to overcome the error "No Servlet class has been specified for servlet" by adding the

           

          <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>

           

          then got a new error:

           

          23:47:50,012 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/rpa].[com.jersey.mywebapp.MyApp]] (http-/127.0.0.1:8080-2) JBWEB000235: Allocate exception for servlet com.

          jersey.mywebapp.MyApp: java.lang.NoSuchMethodError: javax/ws/rs/core/Application.getProperties()Ljava/util/Map;

                  at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:330) [jersey-server-2.19.jar:]

                  at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:339) [jersey-container-servlet-core-2.19.jar:]

                  at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170) [jersey-container-servlet-core-2.19.jar:]

                  at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:362) [jersey-container-servlet-core-2.19.jar:]

                  at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]

                  at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1194) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

                  at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:950) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

                  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:151) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

                  at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

                  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

                  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

                  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

                  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

                  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

                  at java.lang.Thread.run(Thread.java:780) [vm.jar:1.7.0]

           

          resolved this error by commenting out the below tag from {JBOSS_EAP}\modules\system\layers\base\javax\ws\rs\api\main\module.xml

           

          <!--resource-root path="jboss-jaxrs-api_1.1_spec-1.0.1.Final-redhat-2.jar"/-->

          I'm not sure if this is the right approach to get a simple jersey app running in JBoss? Please advise..

          Also wondering why does it take so much tweek to get a simple app running and no documentation/tutorial provides a straight forward steps for getting a jersey RS service running in JBoss