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: Craig McClanahan <Craig.McClanahan_at_Sun.COM>
Date: Fri, 06 Feb 2009 11:37:14 -0800

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();
> }
>