users@jersey.java.net

Re: [Jersey] ClientHandlerException: A message body writer for Java type, class com.sun.jersey.multipart.MultiPart, and MIME media type, application/octet-stream, was not found

From: Gili <cowwoc_at_bbs.darktech.org>
Date: Sun, 14 Dec 2008 09:58:06 -0800 (PST)

I could have sworn I sent out an email explaining where
"application/octet-stream" came from but I can't seem to find it now. Here
is the stack-traceI get if I try POSTing a multipart entity:

com.sun.jersey.client.impl.urlconnection.URLConnectionClientHandler.writeEntity(URLConnectionClientHandler.java:266)
com.sun.jersey.client.impl.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:229)
com.sun.jersey.client.impl.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:191)
com.sun.jersey.api.client.Client.handle(Client.java:347)
com.sun.jersey.api.client.WebResource.handle(WebResource.java:506)
com.sun.jersey.api.client.WebResource.post(WebResource.java:188)

Now, when URLConnectionClientHandler.writeEntity() is invoked, metadata is
an empty map. mediaTypeHeader is then equal to null which means that Jersey
invokes:

   mediaType = new MediaType("application", "octet-stream");

Any ideas on this behavior?

Gili


Craig McClanahan wrote:
>
> Craig McClanahan wrote:
>> The first observation I have is that you *should* really be setting a
>> media type on the body part (there is no default in BodyPart itself).
> Upon further examination, there actually is a default ("text/plain")
> media type for body parts. But there is nowhere in the jersey-multipart
> code that the content type of either the MultiPart instance or any
> BodyPart instance is ever set to "application/octet-stream" -- in fact,
> trying to do this on the MultiPart instance would trigger an exception
> -- so I would also spend a few minutes grepping your source code looking
> for things that might possibly be related:
>
> cd <your project home directory>
> grep -i octet `find . -name '*.java'`
>
> It could also be that the default MBW for byte[] entities tries to set
> this header itself -- I'll try to look at that possibility tomorrow, but
> can't spend more time on it tonight (11:30pm Pacific time right now).
>
> Craig
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
>

-- 
View this message in context: http://n2.nabble.com/ClientHandlerException%3A-A-message-body-writer-for-Java-type%2C-class-com.sun.jersey.multipart.MultiPart%2C-and-MIME-media-type%2C-application-octet-stream%2C-was-not-found-tp1646521p1655102.html
Sent from the Jersey mailing list archive at Nabble.com.