title: Tomcat 7 does not scan annotations when using Jersey 2
body: <p>I have a Jersey 2 Maven project.</p>
  
  <p>web.xml:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!-- This web.xml file is not required when using Servlet 3.0 container,
  see implementation details http://jersey.java.net/nonav/documentation/latest/jax-rs.html --&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;com.api.rest.ApplicationResource&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt;        
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;com.api.rest.ApplicationResource&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/api/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p><strong>pom.xml</strong>:</p>
  
  <pre class="lang-xml prettyprint-override"><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;com.api&lt;/groupId&gt;
      &lt;artifactId&gt;GLI_API&lt;/artifactId&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;GLI_API&lt;/name&gt;
  
      &lt;build&gt;
          &lt;finalName&gt;GLI_API&lt;/finalName&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.5.1&lt;/version&gt;
                  &lt;inherited&gt;true&lt;/inherited&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.8&lt;/source&gt;
                      &lt;target&gt;1.8&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
      &lt;dependencyManagement&gt;
          &lt;dependencies&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.glassfish.jersey&lt;/groupId&gt;
                  &lt;artifactId&gt;jersey-bom&lt;/artifactId&gt;
                  &lt;version&gt;${jersey.version}&lt;/version&gt;
                  &lt;type&gt;pom&lt;/type&gt;
                  &lt;scope&gt;import&lt;/scope&gt;
              &lt;/dependency&gt;
          &lt;/dependencies&gt;
      &lt;/dependencyManagement&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-container-servlet&lt;/artifactId&gt;
              &lt;!-- use the following artifactId if you don't need servlet 2.x compatibility --&gt;
              &lt;!-- artifactId&gt;jersey-container-servlet&lt;/artifactId --&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-media-moxy&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-media-multipart&lt;/artifactId&gt;
              &lt;version&gt;2.21&lt;/version&gt;
          &lt;/dependency&gt;
  
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.zaxxer&lt;/groupId&gt;
              &lt;artifactId&gt;HikariCP-java6&lt;/artifactId&gt;
              &lt;version&gt;2.2.5&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;5.1.36&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;commons-codec&lt;/groupId&gt;
              &lt;artifactId&gt;commons-codec&lt;/artifactId&gt;
              &lt;version&gt;1.9&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-mapper-asl&lt;/artifactId&gt;
              &lt;version&gt;1.9.13&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.mindrot&lt;/groupId&gt;
              &lt;artifactId&gt;jbcrypt&lt;/artifactId&gt;
              &lt;version&gt;0.3m&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;net.sf.json-lib&lt;/groupId&gt;
              &lt;artifactId&gt;json-lib&lt;/artifactId&gt;
              &lt;version&gt;2.4&lt;/version&gt;
              &lt;classifier&gt;jdk15&lt;/classifier&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.cloudinary&lt;/groupId&gt;
              &lt;artifactId&gt;cloudinary-http44&lt;/artifactId&gt;
              &lt;version&gt;1.2.1&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
      &lt;properties&gt;
          &lt;jersey.version&gt;2.19&lt;/jersey.version&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;/properties&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>My project works fine when working locally. But it doesn't work anymore when i deploy it on my remote server. </p>
  
  <p>So what happens is basically, that the WAR gets deployed correctly but there is really no error or warning in catalina.out. I get a 404 on every of my defined endpoints.</p>
  
  <p><strong>catalina.out</strong>:</p>
  
  <pre><code>Sep 14, 2015 2:03:00 PM org.apache.catalina.startup.HostConfig deployWAR
  INFO: Deploying web application archive /var/lib/tomcat7/webapps/GLI_API.war
  Sep 14, 2015 2:04:17 PM org.apache.catalina.startup.HostConfig deployWAR
  INFO: Deploying web application archive /var/lib/tomcat7/webapps/ICDS_API.war
  Sep 14, 2015 2:04:23 PM org.apache.catalina.startup.HostConfig deployDirectory
  INFO: Deploying web application directory /var/lib/tomcat7/webapps/ROOT
  Sep 14, 2015 2:04:23 PM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["http-bio-8080"]
  Sep 14, 2015 2:04:23 PM org.apache.catalina.startup.Catalina start
  INFO: Server startup in 84867 ms
  </code></pre>
  
  <p><strong>ApplicationResource</strong>:</p>
  
  <pre><code>package com.api.rest;
  
  import java.util.logging.Logger;
  
  
  import org.glassfish.jersey.filter.LoggingFilter;
  import org.glassfish.jersey.server.ResourceConfig;
  import org.glassfish.jersey.server.ServerProperties;
  import com.api.provider.ResponseCorsFilter;
  import org.glassfish.jersey.media.multipart.MultiPartFeature;
  
  
  public class ApplicationResource extends ResourceConfig {
  
      private static final Logger LOGGER = null;   
  
  
      public ApplicationResource() {
          // Register resources and providers using package-scanning.
          packages("com.api");
          System.out.println("started");
  
          register(MultiPartFeature.class);
  
          // Register my custom provider - not needed if it's in my.package.
          register(ResponseCorsFilter.class);
          // Register an instance of LoggingFilter.
          register(new LoggingFilter(LOGGER, true));
  
          // Enable Tracing support.
          property(ServerProperties.TRACING, "ALL");
      }
  }
  </code></pre>
  
  <p>What could be the problem? I developed on tomcat8 (but don't remember using something specifically) and deployed on tomcat7. Could this be a problem?</p>
  
  <hr>
  
  <p>This endpoint should be reachable: <a href="http://54.228.220.152:8080/GLI_API/api/item" rel="nofollow">http://54.228.220.152:8080/GLI_API/api/item</a></p>
  
  <p>The other API works fine - so the server in general is working.</p>
  
  <p>Also - if you don't have the final answer i would really appreciate it if you can point me to files/directories to look at since i don't get any error.</p>