title: Jersey - upload images files - error closing message content input stream
body: <p>I'm using jersey for my WS, 
  this is my WS:</p>
  
  <pre><code>     @POST
              @Path("/upload")
              @Consumes(MediaType.MULTIPART_FORM_DATA)
              @Produces({ MediaType.APPLICATION_JSON + ";charset=utf-8" })
              public Response uploadFile(@FormDataParam("file") InputStream fileInputStream, @FormDataParam("file") FormDataContentDisposition contentDispositionHeader, 
                      @Context UriInfo info, @Context HttpHeaders headers) {
      System.out.println("UPLOAD FILE start");
      ...
  }
  </code></pre>
  
  <p>sometimes when client (an android mobile application) send request with images to this WS I get this error:</p>
  
  <pre><code>&lt;09:56:44 IST 07/03/2018&gt; &lt;Error&gt; &lt;HTTP&gt; &lt;BEA-101107&gt; &lt;[ServletContext@1357305147[app:Mobile-V1.0.0-EAR module:Mobile-V1.0.0-EAR path:/Mobile spec-version:2.5]] Problem occurred while serving the error page.
  java.lang.NullPointerException
      at org.springframework.web.context.request.SessionScope.get(SessionScope.java:92)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
      at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956)
      at org.springframework.web.method.HandlerMethod.createWithResolvedBean(HandlerMethod.java:219)
      Truncated. see log file for complete stacktrace
  &gt; 
  checkUser start date:Wed Mar 07 09:56:44 IST 2018
  LOGINURL=http://localhost:8000
  client.target  http://localhost:8000/Entitlement/api/login/customers
  customerId=139
  source :login/customers/139/entitlements
  javax.servlet.ServletException: javax.ws.rs.ProcessingException: Error closing message content input stream.
      at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:419)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:381)
  </code></pre>
  
  <p>After many attempts sometimes client upload the images successfully but sometimes not. This error appear before the WS is start, the "UPLOAD FILE start" line not prints to logs.</p>
  
  <p>Here is a link for site that help me create this WS:
  <a href="https://howtodoinjava.com/jersey/jax-rs-jersey-ajax-multi-file-upload-example/" rel="nofollow noreferrer">jersey multi files upload</a></p>
  
  <p>How can I solve this problem?
  Thanks.</p>