title: URL of a Jersey Application using ResourceConfig without web.xml
body: <p>I migrated from web.xml to totally Java configuration using ResourceConfig with Jersey 2.7 and deploying on Tomcat 7. After that I am not able to reach the services anymore by using the same urls that I was using with the web.xml approach. I don't understand how the ResourceConfig is affecting the paths.</p>
  
  <p>My previous web.xml</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_3_0.xsd"    
  version="3.0"&gt;
  &lt;servlet&gt;
      &lt;servlet-name&gt;my.app&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;
          &lt;param-value&gt;com.mypackage.resource,com.mypackage.providers&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;jersey.config.server.provider.scanning.recursive&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;jersey.config.server.provider.classnames&lt;/param-name&gt;
          &lt;param-value&gt;org.glassfish.jersey.filter.LoggingFilter&lt;/param-value&gt;        
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;org.glassfish.jersey.server.ServerProperties.BV_SEND_ERROR_IN_RESPONSE&lt;/param-name&gt;
          &lt;param-value&gt;true&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;my.app&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p> </p>
  
  <p>My configuration class that extends ResourceConfig is:</p>
  
  <p>MyRESTAPIApp.java</p>
  
  <pre><code>@ApplicationPath("")
  public class MyRESTAPIApp extends ResourceConfig{
      public MyRESTAPIApp () {
          packages("com.mypackage.resource", "com.mypackage.providers");
          register(org.glassfish.jersey.filter.LoggingFilter.class);
          property("jersey.config.beanValidation.enableOutputValidationErrorEntity.server", "true");
      }
  }
  </code></pre>
  
  <p>one of my resources is:</p>
  
  <p>FlagResource.java</p>
  
  <pre><code>@Path("my-resource")
  public class FlagResource {
  private MyService myService = new MyService();
  
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  public FlagResource getFlagResource(@NotNull @QueryParam("level") Long level) {
      FlagResource flagResource = myService.getFlagResource(level);
      return flagResource;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The war that I am generating is called:  my.app.war.</p>
  
  <p>Tomcat was taking the web context root path from the name of the war file as usual, but I don't know if that changes when using Java code based configuration.</p>
  
  <pre><code>GET http://localhost:8080/my.app/my-resource?level=1
  </code></pre>
  
  <p>Returns a 404</p>