3 Replies Latest reply on Mar 21, 2015 3:49 PM by guillaume.clement

    The ResourceConfig instance does not contain any root resource classes.

    nicolas.maujean

      I've successfully deployed and tested a RESTful web service in Tomcat 6. I tried all solutions for the following error message, but still get it, anyone can help ? :

       

       

          {23:17:54,421 ERROR [[/jerseytest]] StandardWrapper.Throwable:      com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.

          at com.sun.jersey.server.impl.application.RootResourceUriRules.<init> (RootResourceUriRules.java:99) [:1.18.1]

           at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1359) [:1.18.1]

          at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:180) [:1.18.1]

          at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:799) [:1.18.1]

       

       

       

       

      Here is the Resource class which is under the WEB-INF/classes directory:

       

       

          package com.rmw.lcf;

         

          import javax.ws.rs.GET;

          import javax.ws.rs.Path;

          import javax.ws.rs.Produces;

         

          /** Example resource class hosted at the URI path "/myresource"

           */

          @Path("/myresource")

          public class MyResource {

             

              /** Method processing HTTP GET requests, producing "text/plain" MIME media

               * type.

               * @return String that will be send back as a response of type "text/plain".

               */

              @GET

              @Produces("text/plain")

              public String getIt() {

                  return "Hi there!";

              }

          }

       

       

      Here's the 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#d4e194 -->

          <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>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>

          <init-param>

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

                      <param-value>com.rmw.lcf.MyApplication</param-value>

                  </init-param>

                  <init-param>

          <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>

          <param-value>com.sun.jersey.api.core.PackagesResourceConfig</param-value>

                  </init-param>

                  <init-param>

                      <param-name>com.sun.jersey.config.property.packages</param-name>

                      <param-value>com.rmw.lcf</param-value>

                  </init-param>

                  <load-on-startup>1</load-on-startup>

              </servlet>

              <context-param>

                  <param-name>resteasy.scan</param-name>

             <param-value>false</param-value>

              </context-param>

          <context-param>

                  <param-name>resteasy.scan.providers</param-name>

              <param-value>false</param-value>

              </context-param>

          <context-param>

              <param-name>resteasy.scan.resources</param-name>

                  <param-value>false</param-value>

          </context-param>

              <servlet-mapping>

                  <servlet-name>Jersey Web Application</servlet-name>

                  <url-pattern>/webresources/*</url-pattern>

              </servlet-mapping>

          </web-app>

        • 1. Re: The ResourceConfig instance does not contain any root resource classes.
          luiz_gustavo

          Hi Nicolas Maujean, I have the same problem. Have you solved this?

           

          I could successfully deploy a REST application in Tomcat, with the same configurations, but when it came to JBoss I got this same error.

           

           

          Here are some additional information.

           

          Jersey dependencies in my project:

           

          <dependency>

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

                 <artifactId>jersey-client</artifactId>

                 <version>1.17.1</version>

          </dependency>

           

          <dependency>

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

                 <artifactId>jersey-json</artifactId>

                 <version>1.17.1</version>

                 <exclusions>

                      <exclusion>

                             <groupId>com.sun.xml.bind</groupId>

                             <artifactId>jaxb-impl</artifactId>

                      </exclusion>

                   </exclusions>

          </dependency>

           

          <dependency>

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

                <artifactId>jersey-server</artifactId>

                <version>1.17.1</version>

                <exclusions>

                      <exclusion>

                            <groupId>asm</groupId>

                            <artifactId>asm</artifactId>

                      </exclusion>

                </exclusions>

          </dependency>

           

          <dependency>

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

               <artifactId>jersey-servlet</artifactId>

               <version>1.17.1</version>

          </dependency>

           

           

          My web.xml configuration:

           

           

            <servlet>

             <servlet-name>Jersey REST Service</servlet-name>

             <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>

             <init-param>

               <param-name>com.sun.jersey.config.property.packages</param-name>

               <param-value>path.to.my.class</param-value>

             </init-param>

             <init-param>

                      <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>

                      <param-value>true</param-value>

                </init-param>

             <load-on-startup>1</load-on-startup>

            </servlet>

            <servlet-mapping>

             <servlet-name>Jersey REST Service</servlet-name>

             <url-pattern>/rest/*</url-pattern>

            </servlet-mapping>

           

           

           

          My resource class:

           

           

          package path.to.my.class;

           

          // imports

           

          @Path("/myPathHere")

          public class RestScimExtensions {

           

            @Path("/ping")

            @GET

            @Produces(MediaType.APPLICATION_JSON)

            public SomeClass ping() { ... }

           

           

           

          Any help is appreciated.

          • 2. Re: The ResourceConfig instance does not contain any root resource classes.
            luiz_gustavo

            Nicolas,

             

            I could make it work in JBoss 6.

             

            I had excluded asm from one of the dependencies, because JBoss already has it, but it was one fo the problems.

             

            This is my final configuration for the jersey dependencies:

             

             

            <dependency>

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

              <artifactId>jersey-client</artifactId>

              <version>1.17.1</version>

              </dependency>

             

              <dependency>

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

              <artifactId>jersey-json</artifactId>

              <version>1.17.1</version>

             

              <exclusions>

              <exclusion>

              <groupId>com.sun.xml.bind</groupId>

                <artifactId>jaxb-impl</artifactId>

              </exclusion>

              </exclusions>

             

              </dependency>

             

              <dependency>

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

              <artifactId>jersey-server</artifactId>

              <version>1.17.1</version>

              </dependency>

             

              <dependency>

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

                 <artifactId>jersey-servlet</artifactId>

                 <version>1.17.1</version>

              </dependency>

             

             

            I had to also remove the com.sun.jersey.config.property.packages parameter from web.xml, and include some context-param.

             

            Here's my final web.xml configuration:

             

            ...

             

            <context-param>

                 <param-name>resteasy.scan</param-name>

                 <param-value>false</param-value>

              </context-param>

              <context-param>

                 <param-name>resteasy.scan.resources</param-name>

                 <param-value>false</param-value>

              </context-param>

              <context-param>

                 <param-name>resteasy.scan.providers</param-name>

                 <param-value>false</param-value>

              </context-param>

             

            ...

             

            <servlet>

               <servlet-name>Jersey REST Service</servlet-name>

               <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>

               <init-param>

                        <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>

                        <param-value>true</param-value>

                  </init-param>

               <load-on-startup>1</load-on-startup>

              </servlet>

              <servlet-mapping>

               <servlet-name>Jersey REST Service</servlet-name>

               <url-pattern>/rest/*</url-pattern>

              </servlet-mapping>

             

             

            I found a tip on this post: http://stackoverflow.com/questions/4412147/the-resourceconfig-instance-does-not-contain-any-root-resource-classes

             

             

            Cheers!

            • 3. Re: The ResourceConfig instance does not contain any root resource classes.
              guillaume.clement

              Thanks for this! Same issue on WildFly 8.x using Jersey 1.18.1. The web.xml changes is all I was missing.