users@jersey.java.net

Re: [Jersey] SEVERE: A message body reader for Java type, class net.nighthawk.ifd.common.auth.UserAuthentication, and MIME media type, application/octet-stream, was not found

From: Aaron Bruegl <abruegl_at_nighthawkrad.net>
Date: Fri, 06 Feb 2009 15:24:14 -0600

Ok, setting the type did work.

Aaron Bruegl wrote:
> I will give this a try. Did 1.0 default to application/xml? I am just
> curious why 1.0 would work.
>
>
> Craig McClanahan wrote:
>> Aaron Bruegl wrote:
>>> I tried today upgrading from Jersey 1.0 to 1.0.1 and 1.0.2-SNAPSHOT
>>> - and got this server side error using 1.0.1 and 1.0.2:
>>>
>>> SEVERE: A message body reader for Java type, class net.MyClass, and
>>> MIME media type, application/octet-stream, was not found
>>>
>>> Is this a known bug at all? Below is a snippet of basically what I
>>> am doing.
>>>
>>>
>>> *Client snippet*
>>>
>>> String id = "someId";
>>> Client client = Client.create();
>>> String resourceUrl = url + "resources/myClasses/" + id;
>>>
>>> WebResource r = client.resource(resourceUrl);
>>> MyClass myClass = new MyClass();
>>> myClass.setId(id);
>>> String s = r.put(u);
>> It looks like you are not specifying a content type on this request,
>> so it will default to "application/octet-stream". You probably want
>> something like this instead (assuming that "u" is something for which
>> the client can create XML content):
>>
>> String s = r.type("application/xml").put(u);
>>
>> Craig
>>
>>>
>>> *Server snippet*
>>> @PUT
>>> @Consumes("application/xml")
>>> @Produces("text/plain")
>>> public void putXml(@PathParam("id")
>>> String id, MyClass content) throws AuthenticationException
>>> {
>>> ...
>>> return content.getId();
>>> }
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>


-- 
Aaron Bruegl