title: REST - Jetty 9 and Jersey 2.6 Multipart file upload
body: <p>I'm trying to create an api to write (upload) a file with <code>Jetty 9.4.7</code> and <code>Jersey 2.26</code>. </p>
  
  <p>The api is structured like this: <code>/api/write</code></p>
  
  <p>I am initializing the server in <code>App.java</code> which is in <code>com.rest.app</code> package. The resource file <code>FileUploadResource.java</code> is in <code>com.rest.res</code> package.</p>
  
  <p>Here's the <code>App.java</code> class:</p>
  
  <pre><code>public class App {
    public static void main(String[] args) {
      Server server = new Server(8500);
  
      final ResourceConfig resourceConfig = new ResourceConfig(FileUploadResource.class);
      resourceConfig.packages("com.rest.res");
      resourceConfig.register(MultiPartFeature.class);
  
      ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
      contextHandler.setContextPath("/");
      server.setHandler(contextHandler);
  
      ServletHolder jerseyServletHolder = contextHandler.addServlet(ServletContainer.class, "/api/*");
      jerseyServletHolder.setInitOrder(0);
  
  
      try {
          server.start();
          server.join();
      } catch (Exception e) {
          e.printStackTrace();
          System.out.println("Stopping server....");
          server.destroy();
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and the here's the <code>FileUploadResource.java</code>:</p>
  
  <pre><code>@Path("/")
  public class FileUploadResource {
      @POST
      @Path("write")
      @Consumes(MediaType.MULTIPART_FORM_DATA)
      @Produces(MediaType.APPLICATION_JSON)
      public Response write(@FormDataParam("file") InputStream fileInputStream,@FormDataParam("file") FormDataContentDisposition contentDisposition) {
  
          // upload file
          // do something
  
          return response;
      }
  }
  </code></pre>
  
  <p>When I send any request, I get this error:</p>
  
  <pre><code>WARNING: Attempt to release request processing resources has failed for a request.
  java.lang.NoSuchMethodError: javax.servlet.http.HttpServletResponse.getStatus()I
  </code></pre>
  
  <p>Here's <code>pom.xml</code> dependency tree:</p>
  
  <pre><code>&lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
          &lt;artifactId&gt;jetty-server&lt;/artifactId&gt;
          &lt;version&gt;9.4.7.v20170914&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
          &lt;artifactId&gt;jetty-servlet&lt;/artifactId&gt;
          &lt;version&gt;9.4.7.v20170914&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-common&lt;/artifactId&gt;
          &lt;version&gt;2.26&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.inject&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-hk2&lt;/artifactId&gt;
          &lt;version&gt;2.26&lt;/version&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.26&lt;/version&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.26&lt;/version&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;version&gt;2.26&lt;/version&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.26&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>Thanks.</p>