title: java.lang.NoClassDefFoundError: org/glassfish/jersey/server/spi/Container
body: <p>I am trying to set up a Jersey 2 servlet application. The goal is to map only some URLs to a Jersey REST API while other URLs serve static content.</p>
  
  <p>I use <code>mvn compile war:war</code> to generate a war and deploy it. When deploying the artifact the following error occurs:</p>
  
  <pre><code>[2016-01-09 02:50:21,617] Artifact Test.war: Artifact is being deployed, please wait...
  2016-01-09 14:50:25.823:WARN:oejd.DeploymentManager:Scanner-1: Unable to reach node goal: started
  java.lang.NoClassDefFoundError: org/glassfish/jersey/server/spi/Container
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
      at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
      at org.eclipse.jetty.webapp.WebAppClassLoader.findClass(WebAppClassLoader.java:549)
      at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:475)
      at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:428)
      at org.eclipse.jetty.util.Loader.loadClass(Loader.java:86)
      at org.eclipse.jetty.servlet.BaseHolder.doStart(BaseHolder.java:95)
      at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:347)
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
      at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:892)
      at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:346)
      at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1380)
      at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342)
      at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:772)
      at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:259)
      at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:518)
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
      at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:41)
      at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:188)
      at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:499)
      at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:147)
      at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:180)
      at org.eclipse.jetty.deploy.providers.WebAppProvider.fileAdded(WebAppProvider.java:459)
      at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64)
      at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:610)
      at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:529)
      at org.eclipse.jetty.util.Scanner.scan(Scanner.java:392)
      at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:329)
      at java.util.TimerThread.mainLoop(Timer.java:555)
      at java.util.TimerThread.run(Timer.java:505)
  Caused by: 
  java.lang.ClassNotFoundException: org.glassfish.jersey.server.spi.Container
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:487)
      at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:428)
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
      at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
      at org.eclipse.jetty.webapp.WebAppClassLoader.findClass(WebAppClassLoader.java:549)
      at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:475)
      at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:428)
      at org.eclipse.jetty.util.Loader.loadClass(Loader.java:86)
      at org.eclipse.jetty.servlet.BaseHolder.doStart(BaseHolder.java:95)
      at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:347)
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
      at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:892)
      at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:346)
      at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1380)
      at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342)
      at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:772)
      at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:259)
      at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:518)
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
      at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:41)
      at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:188)
      at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:499)
      at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:147)
      at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:180)
      at org.eclipse.jetty.deploy.providers.WebAppProvider.fileAdded(WebAppProvider.java:459)
      at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64)
      at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:610)
      at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:529)
      at org.eclipse.jetty.util.Scanner.scan(Scanner.java:392)
      at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:329)
      at java.util.TimerThread.mainLoop(Timer.java:555)
      at java.util.TimerThread.run(Timer.java:505)
  [2016-01-09 02:50:26,121] Artifact Test.war: Error during artifact deployment. See server log for details.
  </code></pre>
  
  <p>my pom.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &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/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;group.id&lt;/groupId&gt;
      &lt;artifactId&gt;ProjectName&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&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;version&gt;2.22.1&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
              &lt;version&gt;2.22.1&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-client&lt;/artifactId&gt;
              &lt;version&gt;2.22.1&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-container-servlet-core&lt;/artifactId&gt;
              &lt;version&gt;2.22.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-container-jetty-http&lt;/artifactId&gt;
              &lt;version&gt;2.22.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-container-jetty-servlet&lt;/artifactId&gt;
              &lt;version&gt;2.22.1&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;finalName&gt;Test&lt;/finalName&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&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;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.6&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;webXml&gt;web/WEB-INF/web.xml&lt;/webXml&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>my web.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
           version="3.1"&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;ApiApplication&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;org.glassfish.jersey.config.property.packages&lt;/param-name&gt;
              &lt;param-value&gt;group.id&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;ApiApplication&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/api/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>The Jersey 2 application configuration ApiApplication.java:</p>
  
  <pre><code>import javax.ws.rs.ApplicationPath;
  
  @ApplicationPath("/api")
  public class ApiApplication extends ResourceConfig {
      public ApiApplication() {
          packages(true, "group.id");
      }
  }
  </code></pre>
  
  <p>The test resource Test.java:</p>
  
  <pre><code>package group.id;
  
  import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  
  @Path("/test")
  public class Test {
      @GET
      public String get() {
          return "Hello world!";
      }
  }
  </code></pre>
  
  <p>When I look into the WAR-file the WEB-INF/lib is filled with JAR-files. Why can't Jetty deploy the WAR-file?</p>