users@jersey.java.net

Message body reader not found - _at_Consumes( "multipart/form-data;boundary=\"foo\"" ) works but @Consumes( "multipart/form-data" ) does not

From: Martin Grotzke <martin.grotzke_at_freiheit.com>
Date: Thu, 31 Jul 2008 15:46:01 +0200

Hi,

we're having issues with our MimeMultipartReader that - AFAIK - worked
before upgrading to the latest jersey (perhaps after the upgrade to
jsr311-0.9).

When we run a test-case this fails with status 415 and this message in
the logs:

Jul 31, 2008 3:33:35 PM com.sun.jersey.spi.container.ContainerRequest getEntity
SEVERE: A message body reader for Java type, interface com.app.proj.api.v1.commons.model.MultipartNameSource, and MIME media type, multipart/form-data;boundary=frontier, was not found

The relevant part of the test-case looks like this:

WebResource r = resource(path);
ClientResponse cr = r.type("multipart/form-data;boundary=\"frontier\"").post(ClientResponse.class, multipartRequest);
Assert.assertEquals(cr.getStatus(), Status.OK.getStatusCode());

(This assertion fails)

The MimeMultipartReader looks like this:

@Consumes( "multipart/form-data" )
@Provider
public class MimeMultipartReader implements MessageBodyReader<MultipartNameSource> {
   ...
}


Interestingly, if I change the value of @Consumes to

@Consumes( "multipart/form-data;boundary=\"frontier\"" )

the test goes through.

Is this a bug or a feature?

What would be the preferred solution for this?

Thanx && cheers,
Martin