2 Replies Latest reply on Aug 14, 2015 8:58 AM by Wolfgang Mayer

    Jersey 2.5.1 throws exception 'No servlet class has been specified for servlet javax.ws.rs.core.Application'

    Sachin Dhingra Newbie

      Hi,

       

      I have JBOSS EAP 6.1.0 GA server on which i am deploying my ear application which contains the jar and war. I am using Jersey 2.5.1 implementation for my restful webservice clases

       

      The war file contains below class:

      @Path("test/{targetName}/{name}")
      public class Test{
          
          @GET
          @Produces(MediaType.APPLICATION_JSON)
          public Response getNextBatch (@PathParam("targetName") String targetName, @PathParam("name") String name) {
              JSONObject test = new JSONObject();
              try {
                  test.put("targetName", "testing");
              } catch (JSONException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
              return Response.status(200).entity(test).build();      
          }
              
      }
      

       

      My lib directory has below jar files:

      jersey-common.jar
      jersey-container-servlet.jar
      jersey-container-servlet-core.jar
      javax.ws.rs-api-2.0.jar
      jersey-server.jar
      

       

      As I have read on https://jersey.java.net/documentation/latest/deployment.html under section 4.7.2. Servlet 3.x Container about deployment without application subclass using web.xml file, my web.xml file looks like:

      <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee;http://java.sun.com/xml/ns/j2ee/web-app_3_0.xsd" version="3.0">
        <display-name>JerseyTest</display-name>
        <welcome-file-list>
          <welcome-file>index.html</welcome-file>
        </welcome-file-list>
      <!-- jersey related mapping -->
        <servlet>
              <servlet-name>javax.ws.rs.core.Application</servlet-name>
              <load-on-startup>1</load-on-startup>
          </servlet>
          <servlet-mapping>
              <servlet-name>javax.ws.rs.core.Application</servlet-name>
              <url-pattern>/resources/*</url-pattern>
          </servlet-mapping>
        <servlet>
      
          <servlet-name>testServlet</servlet-name>
          <servlet-class>com.xxx.servlet.testServlet</servlet-class>
        </servlet>
        <servlet-mapping>
          <servlet-name>testServlet</servlet-name>
          <url-pattern>/testServlet</url-pattern>
        </servlet-mapping>
      

       

      I have commented the jaxrs mapping lines in domain.xml file to avoid conflict with RESTEasy.

       

      When I am deploying my ear file, i am getting below exception:

      00:46:54,637 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/JerseyTest]] (Startup-ApplicationListener) JBWEB000264: Marking servlet javax.ws.rs.core.Application as unavailable
      00:46:54,637 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/JerseyTest]] (Startup-ApplicationListener) JBWEB000289: Servlet javax.ws.rs.core.Application threw load() exception: javax.servlet.ServletException: JBWEB000260: No servlet class has been specified for servlet javax.ws.rs.core.Application
          at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1147) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
          at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1100) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
          at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3591) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:3798) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
          at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:156) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
          at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:60) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
          at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:93) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
          at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [rt.jar:1.6.0_24]
          at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [rt.jar:1.6.0_24]
          at java.util.concurrent.FutureTask.run(FutureTask.java:138) [rt.jar:1.6.0_24]
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_24]
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_24]
          at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_24]
          at org.jboss.threads.JBossThread.run(JBossThread.java:122)
      

       

      Thanks in advance.