users@jersey.java.net

Re: [Jersey] Multipart 1.0.3 not finding message body reader

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 22 Apr 2009 12:19:30 +0200

On Apr 22, 2009, at 11:55 AM, Ari Heino wrote:

>
>
> Paul Sandoz wrote:
>>
>> Hi,
>>
>> What you present below should work, although i recommend utilizing:
>>
>> multiPart.getBodyParts().get(1).getEntityAs(InputStream.class);
>>
>> The functionality to get access to the input stream is fundamental to
>> the higher-level operations with @FormDataParam. We have a number of
>> unit tests that would fail if the available content was zero.
>>
> I am not using @FormDataParam, since I'm using @Consumes("multipart/
> mixed").
> Or should i still use @FormDataParam somewhere in my code?

No, because the body parts are not identified by name. I suppose we
could introduce an ordinal-based extraction annotation e.g.
@BodyPartParam(0) etc.


> Here's the method
> signatur that receives Multipart:
>
> @POST
> @Consumes(MultiPartMediaTypes.MULTIPART_MIXED)
> public Response addRevision(MultiPart multiPart) {
> }
>
>
>> How is the multipart message produced? using the Jersey client API?
>>
> Yes. Here's example of the client side:
> VersionContentDto dto = new VersionContentDto();
> dto.setName("name");
>
> byte[] byteArray = "content test text that does
> stuph".getBytes();
> ByteArrayInputStream bis = new
> ByteArrayInputStream(byteArray);
>
> MultiPart multiPartInput = new MultiPart().bodyPart(new
> BodyPart(dto, MediaType.APPLICATION_XML_TYPE))
> .bodyPart(new BodyPart(bis,
> MediaType.APPLICATION_OCTET_STREAM_TYPE));
>
> r = content.type(
>
> MultiPartMediaTypes.MULTIPART_MIXED).post(ClientResponse.class,
> multiPartInput);
>

Are you using the Jersey 1.0.3 on the client side as well?

There was a bug in 1.0.2 on the client side related to not setting the
boundary string in the media type parameter.


>
>> Would it be possible to send a complete reproducible test case as a
>> maven project?
>>
> We're not using Maven in this project.
>

OK.. NetBeans is fine too, or some zip of source. It just takes me
longer to try and reproduce your problem :-)

Let me write a quick unit test based on the above.

Paul.