users@jersey.java.net

[Jersey] MULTIPART_FORM_DATA WS fails after upgrade to GF 4.1.1

From: Bernie Harris <Bernard.T.Harris_at_nasa.gov>
Date: Tue, 20 Oct 2015 07:56:47 -0400

Since upgrading to GlassFish 4.1.1 (Jersey 2.21) from GlassFish 4.1, a
web service involving multipart form data no longer works. My other web
services (not using multipart form data) are working fine with the new
release. The failing service looks like this
     @POST
     @Path("/translator")
     @Consumes(MediaType.MULTIPART_FORM_DATA)
     @Produces({MediaType.APPLICATION_XML,
                APPLICATION_X_CDFML_XML,
                MediaType.APPLICATION_JSON,
                APPLICATION_X_CDF_JSON,
                APPLICATION_X_CDF,
                APPLICATION_X_NETCDF,
                APPLICATION_X_CDFSKT})
     public Response translate(
         @FormDataParam("file") InputStream fileInputStream,
         @FormDataParam("file") FormDataContentDisposition
             contentDisposition,
         @FormDataParam("data") CDF cdfml,
         @FormDataParam("acceptMediaType") String acceptableMedia,
         @Context UriInfo uriInfo,
         @Context HttpHeaders headers,
         @Context HttpServletRequest servletRequest)
         throws WebApplicationException {

And here is a trace

$ curl -i -H "X-Jersey-Tracing-Threshold: VERBOSE" -H "Accept:
application/xml" -F file=_at_fast_hr_dcb_00000000000000_v01.cdf
http://localhost:8084/WS/file/1/translator/
HTTP/1.1 100 Continue

HTTP/1.1 400 Bad Request
X-Powered-By: Servlet/3.1 JSP/2.3 (GlassFish Server Open Source Edition
4.1.1 Java/Oracle Corporation/1.8)
Date: Tue, 20 Oct 2015 11:15:26 GMT
X-Jersey-Tracing-000: START [ ---- / ---- ms | ---- %]
baseUri=[http://localhost:8084/WS/file/1/]
requestUri=[http://localhost:8084/WS/file/1/translator/] method=[POST]
authScheme=[n/a] accept=[application/xml] accept-encoding=n/a
accept-charset=n/a accept-language=n/a
content-type=[multipart/form-data;
boundary=----------------------------646108391eaf] content-length=[106752]
X-Jersey-Tracing-001: START [ ---- / 0.04 ms | ---- %] Other
request headers: user-agent=[curl/7.19.7 (x86_64-redhat-linux-gnu)
libcurl/7.19.7 NSS/3.18 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2]
host=[localhost:8084] x-jersey-tracing-threshold=[VERBOSE]
expect=[100-continue]
X-Jersey-Tracing-002: PRE-MATCH [ 0.00 / 0.13 ms | 0.01 %]
PreMatchRequest summary: 0 filters
X-Jersey-Tracing-003: MATCH [ ---- / 0.15 ms | ---- %] Matching
path [/translator/]
X-Jersey-Tracing-004: MATCH [ ---- / 0.16 ms | ---- %] Pattern
[/application\.wadl(/)?] is NOT matched
X-Jersey-Tracing-005: MATCH [ ---- / 0.16 ms | ---- %] Pattern
[/application\.wadl(/.*)?] is NOT matched
X-Jersey-Tracing-006: MATCH [ ---- / 0.17 ms | ---- %] Pattern
[(/.*)?] IS selected
X-Jersey-Tracing-007: MATCH [ ---- / 0.18 ms | ---- %] Matching
path [/translator/]
X-Jersey-Tracing-008: MATCH [ ---- / 0.19 ms | ---- %] Pattern
[/translator(/)?] IS selected
X-Jersey-Tracing-009: MATCH [24.39 / 24.54 ms | 64.13 %]
RequestMatching summary
X-Jersey-Tracing-010: REQ-FILTER [ 0.00 / 24.56 ms | 0.00 %] Request
summary: 0 filters
X-Jersey-Tracing-011: RI [ 0.00 / 24.66 ms | 0.01 %]
[org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor @4e852194
#10] BEFORE context.proceed()
X-Jersey-Tracing-012: MBR [ ---- / 24.71 ms | ---- %] Find MBR
for type=[org.glassfish.jersey.media.multipart.FormDataMultiPart]
genericType=[org.glassfish.jersey.media.multipart.FormDataMultiPart]
mediaType=[multipart/form-data;boundary=----------------------------646108391eaf]
annotations=[]
X-Jersey-Tracing-013: MBR [ ---- / 24.74 ms | ---- %]
[org.glassfish.jersey.media.multipart.internal.MultiPartReaderServerSide
@486f1bc] IS readable
X-Jersey-Tracing-014: MBR [ ---- / 24.75 ms | ---- %]
[com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider @112559f7] is
skipped
X-Jersey-Tracing-015: MBR [ ---- / 24.75 ms | ---- %]
[org.glassfish.jersey.jaxb.internal.XmlCollectionJaxbProvider$General
@50bad03f] is skipped
X-Jersey-Tracing-016: MBR [ ---- / 24.76 ms | ---- %]
[org.glassfish.jersey.jaxb.internal.XmlRootElementJaxbProvider$General
@50fcc835] is skipped
X-Jersey-Tracing-017: MBR [ ---- / 24.76 ms | ---- %]
[org.glassfish.jersey.jaxb.internal.XmlRootObjectJaxbProvider$General
@1e14ccb5] is skipped
X-Jersey-Tracing-018: MBR [11.57 / 36.34 ms | 30.42 %] ReadFrom
by
[org.glassfish.jersey.media.multipart.internal.MultiPartReaderServerSide
@486f1bc]
X-Jersey-Tracing-019: RI [ 0.00 / 36.36 ms | 0.00 %]
[org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor @4e852194
#10] AFTER context.proceed()
X-Jersey-Tracing-020: RI [11.72 / 36.36 ms | 30.80 %] ReadFrom
summary: 1 interceptors
X-Jersey-Tracing-021: INVOKE [ ---- / 37.88 ms | ---- %] Response:
null
X-Jersey-Tracing-022: RESP-FILTER [ 0.00 / 38.02 ms | 0.01 %] Filter by
[gov.nasa.gsfc.spdf.file.translator.CorsResponseFilter @3e6bf902]
X-Jersey-Tracing-023: RESP-FILTER [ 0.02 / 38.02 ms | 0.05 %] Response
summary: 1 filters
X-Jersey-Tracing-024: FINISHED [ ---- / 38.04 ms | ---- %] Response
status: 400/CLIENT_ERROR|Bad Request
Content-Language:
Content-Type: text/html
Connection: close
Transfer-Encoding: chunked

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html
xmlns="http://www.w3.org/1999/xhtml"><head><title>Error
report</title><style type="text/css"><!--H1
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
H2
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
H3
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
BODY
{font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}
P
{font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
{color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP
Status 400 - Bad Request</h1><hr/><p><b>type</b> Status
report</p><p><b>message</b>Bad Request</p><p><b>description</b>The
request sent by the client was syntactically
incorrect.</p><hr/></body></html>

Has something changed that requires me to change my code or is this a
problem with jersey? Thanks for any insight.

Bernie