title: "com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes" error on Jersey Rest
body: <p>I know this questions been before on this site but I have taken advice from these pages and haven't been able resolve the problem yet. When trying to run a Rest Web Service using Jersey, I come across the following error message:-</p>
  
  <p><strong><em>EXCEPTION</em></strong></p>
  
  <pre><code>javax.servlet.ServletException: Servlet.init() for servlet Jersey REST Service threw exception
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
      org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
      org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
      org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
      java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      java.lang.Thread.run(Thread.java:724)
  </code></pre>
  
  <p><strong><em>ROOT CAUSE</em></strong></p>
  
  <pre><code>com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
      com.sun.jersey.server.impl.application.RootResourceUriRules.&lt;init&gt;(RootResourceUriRules.java:99)
      com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1359)
      com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:180)
      com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:799)
      com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:795)
      com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
      com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:795)
      com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:790)
      com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:491)
      com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:321)
      com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605)
      com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207)
      com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:376)
      com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:559)
      javax.servlet.GenericServlet.init(GenericServlet.java:160)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
      org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
      org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
      org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
      java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      java.lang.Thread.run(Thread.java:724)
  </code></pre>
  
  <p>After doing the reasearch, i have narowed it down to 3 problems:-</p>
  
  <ol>
  <li>Errors within the web.xml.</li>
  <li>No resources used within packaged project.</li>
  <li>Problems with .jar files.</li>
  </ol>
  
  <p>I have edited the web.xml as much as possible and have gotten nowhere with it. Below is the current web.xml file i am using.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt;
    &lt;display-name&gt;com.epware.jersey.book&lt;/display-name&gt;
    &lt;servlet&gt;
      &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
      &lt;init-param&gt;
        &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
        &lt;param-value&gt;com.epware.jersey.book.resources&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 REST Service&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>I cannot locate any problems within the linked package. This is probably where the error is but i am struggling to find it myself. Again, the code for this is below.</p>
  
  <pre><code>// Will map the resource to the URL todos
  @Path("/books")
  public class BooksResource {
  
      @Context
      UriInfo uriInfo;
      @Context
      Request request;
  
  
      @GET
      @Produces(MediaType.TEXT_XML)
      public List&lt;Book&gt; getBooksBrowser() {
          List&lt;Book&gt; books = new ArrayList&lt;Book&gt;();
          books.addAll( BookDao.instance.getModel().values() );
          return books; 
      }
  
      @GET
      @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
      public List&lt;Book&gt; getBooks() {
          List&lt;Book&gt; books = new ArrayList&lt;Book&gt;();
          books.addAll( BookDao.instance.getModel().values() );
          return books; 
      }
  
      @GET
      @Path("count")
      @Produces(MediaType.TEXT_PLAIN)
      public String getCount() {
          int count = BookDao.instance.getModel().size();
          return String.valueOf(count);
      }
  
      @POST
      @Produces(MediaType.TEXT_HTML)
      @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
      public void newBook(
              @FormParam("id") String id,
              @FormParam("title") String title,
              @FormParam("description") String description,
              @FormParam("authorFirst") String authorFirst,
              @FormParam("authorSecond") String authorSecond,
              @FormParam("publisher") String publisher,
              @FormParam("publishDate") String publishDate,
              @Context HttpServletResponse servletResponse
      ) throws IOException {
          Book book = new Book(id,title,description,authorFirst,authorSecond,publisher,publishDate);
          BookDao.instance.getModel().put(id, book);
          System.out.println(BookDao.instance.getModel().toString());
          servletResponse.sendRedirect("../create_todo.html");
      }
  
      @Path("{book}")
      public BookResource getBook(
              @PathParam("book") String id) {
          return new BookResource(uriInfo, request, id);
      }
  
  }
  </code></pre>
  
  <p>I am currently using Jersey jars version 1.18 as shown in the image below:-</p>
  
  <p>External Link to Image : <a href="http://i.stack.imgur.com/j6tpC.png" rel="nofollow">http://i.stack.imgur.com/j6tpC.png</a></p>
  
  <p>Any help is greatly appreciated a i am on limited time now to get this done.</p>