FYI, I have the following jersey jars in my app's classpath along with the mimepull jar version as:
jersey-apache-client-1.11.jar
jersey-apache-client4-1.11.jar
jersey-client-1.17.1.jar
jersey-core-1.17.1.jar
jersey-guice-1.17.1.jar
jersey-json-1.17.1.jar
jersey-multipart-1.17.1.jar
jersey-server-1.17.1.jar
jersey-servlet-1.11.jar
mimepull-1.6.jar
I even tried with all of them either 1.11 or 1.17.1 for the jersey specific jars. When I tried to submit a file upload request via my latest Chrome browser (here is the client side html code to submit the file upload):
<form name="uploadFile" action="/app/fileUpload" method="post" enctype="multipart/form-data">
<input type="file" name="file" class="input-file"/><br/>
<button type="submit" id="upload-btn" class="btn btn-primary">Upload</button>
</form>
Strangely enough, my file upload jersey resource is not even hit and I get a 400 error in my Chrome browser with the following exception in my server logs, however it works just fine in my Firefox browser:
[toResponse] WebApplicationExceptionMapper status='400' message='org.jvnet.mimepull.MIMEParsingException: Missing start boundary' url='/app/fileUpload'
javax.ws.rs.WebApplicationException: org.jvnet.mimepull.MIMEParsingException: Missing start boundary
at com.sun.jersey.multipart.impl.MultiPartReaderClientSide.readFrom(MultiPartReaderClientSide.java:146)
at com.sun.jersey.multipart.impl.MultiPartReaderClientSide.readFrom(MultiPartReaderClientSide.java:82)
at com.sun.jersey.spi.container.ContainerRequest.getEntity(ContainerRequest.java:488)
at com.sun.jersey.spi.container.ContainerRequest.getEntity(ContainerRequest.java:552)
at com.sun.jersey.multipart.impl.FormDataMultiPartDispatchProvider$FormDataInjectableValuesProvider.getInjectableValues(FormDataMultiPartDispatchProvider.java:122)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$EntityParamInInvoker.getParams(AbstractResourceMethodDispatchProvider.java:153)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:203)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1511)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1442)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1391)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1381)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
...
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
at java.lang.Thread.run(Thread.java:724)
Caused by: org.jvnet.mimepull.MIMEParsingException: Missing start boundary
at org.jvnet.mimepull.MIMEParser.skipPreamble(MIMEParser.java:306)
at org.jvnet.mimepull.MIMEParser.access$300(MIMEParser.java:67)
at org.jvnet.mimepull.MIMEParser$MIMEEventIterator.next(MIMEParser.java:143)
at org.jvnet.mimepull.MIMEParser$MIMEEventIterator.next(MIMEParser.java:128)
at org.jvnet.mimepull.MIMEMessage.makeProgress(MIMEMessage.java:198)
at org.jvnet.mimepull.MIMEMessage.parseAll(MIMEMessage.java:181)
at org.jvnet.mimepull.MIMEMessage.getAttachments(MIMEMessage.java:106)
at com.sun.jersey.multipart.impl.MultiPartReaderClientSide.readMultiPart(MultiPartReaderClientSide.java:187)
at com.sun.jersey.multipart.impl.MultiPartReaderServerSide.readMultiPart(MultiPartReaderServerSide.java:80)
at com.sun.jersey.multipart.impl.MultiPartReaderClientSide.readFrom(MultiPartReaderClientSide.java:144)
... 46 more
Here is the Request payload which also looks correct when compared with Firefox payload, I dont understand why I see 400 for the same request in Chrome browser but 200OK in Firefox
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryNkIU5AivMR0pDmZG
Host:localhost:8080
Origin:http://localhost:8080
Referer:http://localhost:8080/app/files
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36
Request Payload
------WebKitFormBoundaryNkIU5AivMR0pDmZG
Content-Disposition: form-data; name="file"; filename="file.zip"
Content-Type: application/zip
------WebKitFormBoundaryNkIU5AivMR0pDmZG--
Any pointers to resolve this error will be highly appreciated. Please let me know if you need any more information from my side to get further insight into the issue.
Here is the Jersey resource method signature:
@POST
@Path("/fileUpload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadMultiPartFormData(@FormDataParam("file") InputStream file_in,
@FormDataParam("file")FormDataContentDisposition fileName) throws Exception {