title: com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes
body: <p>I am getting the following exception when I try to hit a HelloWorld RESTful web service implemented using Jersey and maven on Apache Tomcat.</p>
  
  <pre><code>URL: http://localhost:8080/TestRest/rest/hello/abcd
  </code></pre>
  
  <p>com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.</p>
  
  <p>I looked at various sources on internet, they say the exception occurs because of not having class in the package structure given in web.xml, but I made sure that they are all correct.</p>
  
  <p>Any help regarding this is greatly appreciated.</p>
  
  <p>Following is the code of pom.xml</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
        &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
        &lt;groupId&gt;my.test.rest&lt;/groupId&gt;
        &lt;artifactId&gt;TestRest&lt;/artifactId&gt;
        &lt;packaging&gt;war&lt;/packaging&gt;
        &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
        &lt;name&gt;TestRest Maven Webapp&lt;/name&gt;
        &lt;url&gt;http://maven.apache.org&lt;/url&gt;
        &lt;repositories&gt;
                  &lt;repository&gt;
                  &lt;id&gt;maven2-repository.java.net&lt;/id&gt;
                  &lt;name&gt;Java.net Repository for Maven&lt;/name&gt;
                  &lt;url&gt;http://download.java.net/maven/2/&lt;/url&gt;
                  &lt;layout&gt;default&lt;/layout&gt;
          &lt;/repository&gt;
    &lt;/repositories&gt;
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;3.8.1&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
              &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
              &lt;version&gt;1.8&lt;/version&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
    &lt;build&gt;
      &lt;finalName&gt;TestRest&lt;/finalName&gt;
    &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>This is the simple HelloWorldService.</p>
  
  <pre><code>package com.rest;
  
  import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.PathParam;
  import javax.ws.rs.core.Response;
  
  @Path("/hello")
  public class HelloWorldService {
  
      @GET
      @Path("/{param}")
      public Response getMsg(@PathParam("param") String msg) {
  
          String output = "Hello, " + msg;
  
          return Response.status(200).entity(output).build();
  
      }
  
  }
  </code></pre>
  
  <p>And finally, the web.xml</p>
  
  <pre><code>&lt;web-app id="WebApp_ID" version="2.4"
      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_2_4.xsd"&gt;
      &lt;display-name&gt;Restful Web Application&lt;/display-name&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;HelloServlet&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.rest&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;HelloServlet&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 hope the directory structure of mine is correct too, please correct me if it isn't.</p>
  
  <p><img src="https://i.stack.imgur.com/jpJqH.png" alt="Directory Structure"></p>