users@jersey.java.net

RE: [Jersey] JAXB not working

From: Markus KARG <markus.karg_at_gmx.net>
Date: Mon, 22 Jun 2009 19:49:39 +0200

Paul,

 

I am such an idiot... Thanks for your explanations! :-)

 

Thanks

Markus

 

From: Paul.Sandoz_at_Sun.COM [mailto:Paul.Sandoz_at_Sun.COM]
Sent: Montag, 22. Juni 2009 17:04
To: users_at_jersey.dev.java.net
Subject: Re: [Jersey] JAXB not working

 

 

On Jun 22, 2009, at 4:47 PM, Markus Karg wrote:





I want to provide a XML body to a PUT method, using an application provided
JAXB class.

 

The class is marked as @XmlRootElement, and the method is like this:

 

@PUT

@Path("{fileName}.xml")

@Consumes("application/xml")

public final void put(final MyJaxbClass body)

 

The JAX-RS specification says: "If an application does not supply a
JAXBContext for a particular type, the implementation-supplied entity
provider MUST use its own default context instead."

 

In fact, my implementation of the Application interface does NOT provide a
JAXBContext for MyJaxbClass (while it does for other JAXB classes).

 

The caller sends an "Accept: application/xml" header in the request.

 

 

You need to set "Content-Type: application/xml".

 

The Accept header is for what the server produces and the client consumes.
The Content-Type header is for what the server consumes and the client
produces.

 





So I wonder why Jersey always says that it cannot find a message body ready
for "application/octetstream"...?

 

The used JAX-RS version is 1.0.3.

 

Maybe it is a bug?

 

 

The server is defaulting to that because the client has not sent a
Content-Type header (or it set with the value of
"application/octet-stream").

 

You can verify by setting up logging as i described in the previous email.

 





What is my fault?

 

 

I think the client is not setting the Content-Type.

 

Paul.