title: Class not found even though it is clearly visible in Web App Libraries
body: <p><a href="https://stackoverflow.com/q/29185385/12169560">Similar question exists</a> but none of the answers helped.</p>
  <p>Starting Tomcat Server 9 on my Eclipse Project gives the error</p>
  <pre><code>java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer.class
      at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1364)
      at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1187)
      at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:539)
  </code></pre>
  <p>Even though I can clearly see <code>ServletContainer.class</code> under <code>org.glassfish.jersey.servlet</code> under <code>jersey-container-servlet-core.jar</code> under <code>Web App Libraries</code>.</p>
  <p>All the required jars were added to <code>/src/main/webapp/WEB-INF/lib</code>, they seem to be properly imported.</p>
  <p>web.xml:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;web-app xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns=&quot;http://xmlns.jcp.org/xml/ns/javaee&quot; xsi:schemaLocation=&quot;http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd&quot; id=&quot;WebApp_ID&quot; version=&quot;4.0&quot;&gt;
    &lt;display-name&gt;JavaAPI&lt;/display-name&gt;
    
      &lt;servlet&gt;
          &lt;servlet-name&gt;JAVA API&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer.class&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;test&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;!-- Tried Removing this, no difference --&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;JAVA API&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  <p>Hello.java:</p>
  <pre><code>package test;
  
  import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  
  import javax.ws.rs.ApplicationPath;
  import javax.ws.rs.core.Application;
  
  @Path(&quot;/hello&quot;)
  public class Hello {
      
      @GET
      @Produces(MediaType.TEXT_XML)
      public String sayHello() {
          String resource = &quot;&lt;? xml version='1.0' ?&gt;&quot; + 
                      &quot;&lt;hello&gt;Hi Varun! This is the sayHello call.&lt;/hello&gt;&quot;;
          return resource;
      }
      
      @GET
      @Produces(MediaType.APPLICATION_JSON)
      public String sayHelloJSON() {
          String resource = null;
          return resource;
      }
      
      @GET
      @Produces(MediaType.TEXT_HTML)
      public String sayHelloHTML() {
          String resource = &quot;&lt;h1&gt;Hi Varun! This is the sayHelloHTML call.&lt;/h1&gt;&quot;;
          return resource;
      }
  }
  </code></pre>
  <p>Project Structure:<br />
  <a href="https://i.stack.imgur.com/vfy3M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vfy3M.png" alt="Project Structure" /></a></p>
  <p>Using:</p>
  <ul>
  <li>Eclipse: 2021-03</li>
  <li>Tomcat: 9</li>
  <li>Java: 1.8 (set under BuildPath, ProjectFacets)</li>
  <li>JAX-RS 2.0 / Jersey 2.25.x</li>
  </ul>
  <p>No Maven, Gradle involved, simply web project, with every jar hand-picked and imported.</p>
  <p>Was following <a href="https://www.youtube.com/watch?v=5jQSat1cKMo" rel="nofollow noreferrer">this tutorial step-by-step</a>.</p>