title: Servlet class com.foobar.jaxrs.application.MyApplication is not a javax.servlet.Servlet
body: <p>I'm trying to configure Jersey with Servlet 3.1 and an Application Subclass. Been reading documentation for a while and trying to get this going, but i'm not sure what's wrong here.</p>
  
  <p>web.xml (though I shouldn't need one I get a 404 without one...)</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
  id="WebApp_ID" version="3.1"&gt;
  
  &lt;display-name&gt;Foobar Models&lt;/display-name&gt;
  
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  
  &lt;session-config&gt;
      &lt;session-timeout&gt;30&lt;/session-timeout&gt;
      &lt;cookie-config&gt;
          &lt;name&gt;SESSIONID&lt;/name&gt;
      &lt;/cookie-config&gt;
  &lt;/session-config&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;Foo Bar Application&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.foobar.jaxrs.application.FooBarApplication&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Foo Bar Application&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/api/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Application Subclass</p>
  
  <pre><code>package com.foobar.jaxrs.application;
  
  import java.util.HashSet;
  import java.util.Set;
  
  import javax.ws.rs.ApplicationPath;
  import javax.ws.rs.core.Application;
  
  @ApplicationPath("/api")
  public class FooBarApplication extends Application {
  public Set&lt;Class&lt;?&gt;&gt; getClasses() {
      Set&lt;Class&lt;?&gt;&gt; s = new HashSet&lt;Class&lt;?&gt;&gt;();
      s.add(com.foobar.api.HealthCheckResource.class);
      return s;
  }
  }
  </code></pre>
  
  <p>HealthCheckResource.java</p>
  
  <pre><code>package com.foobar.api;
  
  import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  
  @Path("health")
  public class HealthCheckResource {
  
      @GET
      @Produces("text/html")
      public String getHeath() {
          return "Foo Bar Application is healthy!";
      }
  
  }
  </code></pre>
  
  <p>Running in jetty (same in Tomcat 8)</p>
  
  <pre><code>HTTP ERROR 404
  
  Problem accessing /foobar/api/health. Reason:
  
      Servlet class com.foobar.jaxrs.application.FooBarApplication is not a javax.servlet.Servlet
  Caused by:
  
  javax.servlet.UnavailableException: Servlet class com.foobar.jaxrs.application.FooBarApplication is not a javax.servlet.Servlet
      at org.mortbay.jetty.servlet.ServletHolder.checkServletType(ServletHolder.java:362)
      at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:243)
      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
      at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:685)
  ....
  </code></pre>