title: Spring Boot with Jersey as Servlet in Tomcat
body: <p>I try to deploy a simple Jersey application to my Tomcat-Server. But the Endpoint is not responding (404). </p>
  
  <p>When I start this application as a Spring Boot application, everything works. But as a Servlet in Tomcat, the TestEndpoint is not working.</p>
  
  <p>Servlet:</p>
  
  <pre><code>@SpringBootApplication
  public class ServletInitializer extends SpringBootServletInitializer {
  
      public static void main(String[] args) {
          SpringApplication.run(ServletInitializer.class, args);
      }
      @Override
      protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
          return application.sources(ServletInitializer.class);
      }
  }
  </code></pre>
  
  <p>I have 3 files:
  JerseyConfig:</p>
  
  <pre><code>@Configuration
  public class JerseyConfig extends ResourceConfig {
      public JerseyConfig() {
          packages("com.example");
          register(TestEndpoint.class);
      }
  }
  </code></pre>
  
  <p>TestEndpoint:</p>
  
  <pre><code>@Component
  @Path("/test")
  public class TestEndpoint {
      private final Logger log = LoggerFactory.getLogger(this.getClass());
      @GET
      @Path("/test")
      @Produces("application/json")
      public Response test () {
          log.error("test");
          return Response.ok("test").build();
      }
  }
  </code></pre>
  
  <p>pom.xml:</p>
  
  <p>
  http://maven.apache.org/xsd/maven-4.0.0.xsd">
      4.0.0</p>
  
  <pre><code>&lt;groupId&gt;com.example&lt;/groupId&gt;
  &lt;artifactId&gt;demo&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  
  &lt;name&gt;demo&lt;/name&gt;
  &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
  &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;1.4.2.RELEASE&lt;/version&gt;
      &lt;relativePath/&gt; 
  &lt;/parent&gt;
  
  &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-jersey&lt;/artifactId&gt;
          &lt;version&gt;1.4.1.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p></p>
  
  <p>Request:
  As application: curl <a href="http://localhost:8080/test/test" rel="nofollow noreferrer">http://localhost:8080/test/test</a> (works)
  As servlet (api.war): <a href="http://localhost:8080/api/test/test" rel="nofollow noreferrer">http://localhost:8080/api/test/test</a> (does not work)
  Any ideas?</p>