title: Deployment of a JAX-RS application using web.xml, Servlet 3.0 and Jersey
body: <p>I'm trying to deploy my application, using web.xml, servlet 3.0, and jersey API. Unfortunately, it doesn't work.</p>
  
  <p>This is MyApplication.class :</p>
  
  <pre><code>package com.example;
  
  public class MyApplication 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(MyResource.class);
         return s;
     }
  }
  </code></pre>
  
  <p>This is MyResource : </p>
  
  <pre><code>@Path("/helloworld")
  @Produces(MediaType.TEXT_PLAIN)
  public class MyResource {
      @GET
      public String getHello() {
          return "HelloWorld !";
      }
  }
  </code></pre>
  
  <p>And my web.xml :</p>
  
  <pre><code> &lt;web-app&gt;
       &lt;servlet&gt;
           &lt;servlet-name&gt;com.example.MyApplication&lt;/servlet-name&gt;
       &lt;/servlet&gt;
       &lt;servlet-mapping&gt;
           &lt;servlet-name&gt;com.example.MyApplication&lt;/servlet-name&gt;
           &lt;url-pattern&gt;/webapi/*&lt;/url-pattern&gt;
       &lt;/servlet-mapping&gt;
   &lt;/web-app&gt;
  </code></pre>
  
  <p>On client side, I'm using this url : 
       http://localhost:8080/[projectname]/webapi/helloworld</p>
  
  <p>And i have this error : </p>
  
  <pre><code>java.lang.NullPointerException
      sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
      java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1629)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:491)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
      org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
      org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
      org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
      org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
      java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
      java.lang.Thread.run(Thread.java:662)
  </code></pre>
  
  <p>What's wrong ? :/ I'm using Tomcat 7.</p>
  
  <p>PS : with a servlet 2.x, it works :</p>
  
  <pre><code>    &lt;servlet&gt;
          &lt;servlet-name&gt;Jersey Web Application&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;jersey.config.server.provider.packages&lt;/param-name&gt;
              &lt;param-value&gt;com.example&lt;/param-value&gt;
          &lt;/init-param&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Jersey Web Application&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/webapi/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>but i will need asynchronous mode later.</p>
  
  <p>Thanks !</p>