users@jersey.java.net

Re: [Jersey] A message body writer for Java type [...] and MIME media type [...] was not found

From: Javier Alvarez <javier.alvarez_at_bsc.es>
Date: Wed, 12 May 2010 09:07:55 +0200

Hi Moises,

I forgot to say that I get the error when invoking the following POST
method:

@POST
@Consumes ("application/vdc+xml")
@Path ("/vdc/action/add")
public Response addVDC (VDCType vdc)
{
     System.out.println(vdc.getName());

     return Response.ok(vdc, "application/vdc+xml").build();
}

And then:

- If I add @XmlRootElement to the VDCType class I get an HTTP 400
Response saying that the sent resource is sintactically incorrect and
the method above prints nothing.

- Without the @XmlRootElement I can invoke the method and it prints the
correct name, but it crashes when returning.

By the way, if I change the type to "application/xml" I have the same
problem.

Thank you.

On 12/05/10 08:34, Moises Lejter wrote:
> Maybe you should designate your class as @XmlRootElement, too ?
> I would have expected that the default XML encoding would be
> acceptable, even though you say "application/cvd+xml", and not just
> "application/xml" ...
>
> Moises
>
> On May 12, 2010, at 1:27 AM, Javier Alvarez wrote:
>
>> I am developing a RESTful Web Service using Jersey and I encountered
>> a problem. The error is the following:
>>
>> /A message body writer for Java type, class VDCType, and MIME media
>> type, application/vdc+xml, was not found./
>
-- 
Javi