Note that there are some explanatory texts on larger screens.

plurals
  1. POJetty throws "Missing content for multipart request" on multipart form request
    text
    copied!<p>I'm running Jetty 9 (jetty-9.0.5.v20130815) server with servlet-api 3.0.1 (javax.servlet:javax.servlet-api:3.0.1), my servlet is configured to accept multipart requests.</p> <p>web.xml -</p> <pre><code>&lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"&gt; &lt;servlet&gt; &lt;servlet-name&gt;restapi&lt;/servlet-name&gt; &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet &lt;/servlet-class&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;multipart-form enable="true" /&gt; &lt;multipart-config&gt; &lt;max-file-size&gt;8428800&lt;/max-file-size&gt; &lt;max-request-size&gt;8428800&lt;/max-request-size&gt; &lt;file-size-threshold&gt;1048576&lt;/file-size-threshold&gt; &lt;/multipart-config&gt; &lt;/servlet&gt; &lt;/web-app&gt; </code></pre> <p>applicationContext.xml -</p> <pre><code>&lt;bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt; &lt;!-- one of the properties available; the maximum file size in bytes --&gt; &lt;property name="maxUploadSize" value="8000000"/&gt; &lt;/bean&gt; </code></pre> <p>It implements a POST command that should receive a file upload through <code>HttpServletRequest</code>. But when <code>request.getParts()</code> is called, this exception occurs:</p> <pre><code>java.io.IOException: Missing content for multipart request at org.eclipse.jetty.util.MultiPartInputStreamParser.parse(MultiPartInputStreamParser.java:493) at org.eclipse.jetty.util.MultiPartInputStreamParser.getParts(MultiPartInputStreamParser.java:401) at org.eclipse.jetty.server.Request.getParts(Request.java:2077) at javax.servlet.http.HttpServletRequestWrapper.getParts(HttpServletRequestWrapper.java:351) at javax.servlet.http.HttpServletRequestWrapper.getParts(HttpServletRequestWrapper.java:351) </code></pre> <p>The client is an iOS app using ASIFormDataRequest, but I don't think that client has the problem because it used to work with Apache commons-fileupload.jar. I'm not switching the server to use Jetty's multipart support for receiving files.</p> <p>Here's the request, as intercepted by a proxy -</p> <pre><code>POST /mycommand HTTP/1.1 Host: localhost:8080 Proxy-Connection: close Accept-Encoding: gzip Content-Type: multipart/form-data; charset=utf-8; boundary=0xKhTmLbOuNdArY-849F4DA3-85DC-46F1-B182-44257808F0B9 Content-Length: 1568 Connection: close --0xKhTmLbOuNdArY-849F4DA3-85DC-46F1-B182-44257808F0B9 Content-Disposition: form-data; name="param1" text --0xKhTmLbOuNdArY-849F4DA3-85DC-46F1-B182-44257808F0B9 Content-Disposition: form-data; name="data"; filename="file" Content-Type: application/octet-stream ... DATA ... --0xKhTmLbOuNdArY-849F4DA3-85DC-46F1-B182-44257808F0B9-- </code></pre> <p>Any ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload