title: Jersey REST webservice subresources not found
body: <p>At first in my web server I only had one REST servlet. Something like:</p>
  
  <pre><code>@Path("/")
  public class Controller {
    @GET
    @Produces({ MediaType.TEXT_HTML })
    public Response get(@Context UriInfo info) throws Exception {
      ...
    }
  
    @GET
    @Path("resource1")
    @Produces({ MediaType.TEXT_HTML })
    public Response resource1() throws Exception {
      ...
    }
  
    ...
  
   }
  </code></pre>
  
  <p>And the web.xml:</p>
  
  <pre><code> &lt;servlet&gt;
      &lt;servlet-name&gt;rest&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;xpto.mypack1;xpto.mypack2&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;rest&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>But then I wanted to add some static html to the server, so I updated the servlet mapping to
      /rest/*</p>
  
  <p>and the @Path directive of Controller servlet class from "/" to "/rest". Everything works fine but the sub-resources or methods of controller with the @path directive that stopped working.. ie:</p>
  
  <ul>
  <li>/ works fine since I have an index.html page at root</li>
  <li>/rest works fine, it invokes the get method of my servlet</li>
  <li>/rest/resource1 returns 404 http code...</li>
  </ul>
  
  <p>Any help? I already tried a list of combinations of / after and before each @Path directive, with no success... Many thanks</p>
  
  <p>One update:</p>
  
  <p>I used the trace util and got the following results:</p>
  
  <p>for /[app-name]/rest (it works):</p>
  
  <ul>
  <li>X-Jersey-Trace-002    accept right hand path java.util.regex.Matcher[pattern=/rest(/.*)? region=0,11 lastmatch=/rest]: "/rest" -> "/rest" : ""</li>
  <li>X-Jersey-Trace-003    accept resource: "rest" -> @Path("/rest") xpto.mypack.Controller</li>
  <li>X-Jersey-Trace-000    accept root resource classes: "/rest"</li>
  <li>X-Jersey-Trace-001    match path "/rest" -> "/application.wadl(/.<em>)?", "/rest(/.</em>)?"</li>
  </ul>
  
  <p>for /[app-name]/rest/resource1 (it doesn't work):</p>
  
  <ul>
  <li>X-Jersey-Trace-002    matched exception mapper: com.sun.jersey.api.NotFoundException@4fd41dc3 -> xpto.myclass</li>
  <li>X-Jersey-Trace-003    mapped exception to response: com.sun.jersey.api.NotFoundException@4fd41dc3 -> 404 (Not Found)
  X-Jersey-Trace-000  accept root resource classes: "/resource1"
  X-Jersey-Trace-001  match path "/resource1" -> "/application.wadl(/.<em>)?", "/rest(/.</em>)?"</li>
  </ul>
  
  <p>I hope it helps someone to help me..</p>