users@wadl.java.net

wadl2java: exception when marshalling generated JavaBeans to XML in request bodies

From: <michaelw_at_articulatedesign.us.com>
Date: Tue, 13 May 2014 20:13:19 +0000 (UTC)

I ran wadl2java 1.1.6 to generate JavaBeans from WADL and used the
beans in my Jersey 2.7 client. There are no problems unmarshalling an
XML response using the generated beans. However, if a request body
content is XML, marshalling fails with an exception:

org.glassfish.jersey.message.internal.WriterInterceptorExecutor$Termina
lWriterInterceptor aroundWriteTo
SEVERE: MessageBodyWriter not found for media type=application/xml,
type=class com.ltree.airportweather.AirportInfo,
genericType=class com.ltree.airportweather.AirportInfo.

If I manually add @XmlRootElement to the generated bean, the request
succeeds.

I get the same result when sending requests from the generated custom
class (i.e., the generated JAX-RS client with methods for all the
requests in the WADL).

Here's my code:

AirportInfo airportInfoBean = new AirportInfo(); // generated by
wadl2java
...
Client client = ClientBuilder.newClient();
String responseFromPost =
        client.target(BASE_URL)
              .request(MediaType.TEXT_PLAIN)
              .post(Entity.xml(airportInfoBean), String.class);

Any idea what I'm doing wrong? Should I be using the generated
ObjectFactory somewhere in my client code?

Thanks,
Mike