It looks like the problem is in returning a Response with the Collection set as the entity, as described below. Changing the return type to List<JobImpl> works as expected.
Thanks, Josh On Wed, Oct 6, 2010 at 10:10 AM, Josh Holtzman <[email protected]>wrote: > When I do this: > > @GET > @Path("/jobs.xml") > @Produces(MediaType.APPLICATION_XML) > public Response getJobs() { > return Response.ok(getJobsImpls()).build(); > } > > @XmlType(name = "job", namespace = "http://remote.opencastproject.org/") > @XmlRootElement(name = "job", namespace = " > http://remote.opencastproject.org/") > public class JobImpl implements Job { > ... > } > > > I get a 500 response with this in the body "No message body writer has been > found for response class Vector." I thought maybe the problem was that this > Vector is the one being returned by eclipselink, and there was some kind of > proxy voodoo interfering. If I copy all of the JobImpls into a new > ArrayList, I get the same kind of message, "No message body writer has been > found for response class ArrayList." > > I'm building the JAX-RS endpoint manually using cxf-bundle-jaxrs-2.2.9.jar > and a CXFNonSpringServlet with some custom providers. Perhaps I'm missing > one of the providers needed to handle Collections? > > And I'm curious, what would the xml look like for this collection? Where > does the root element name come from? And the namespace... is it copied > from the objects in the collection? > > Thanks, > Josh > > On Tue, Oct 5, 2010 at 11:20 PM, Sergey Beryozkin <[email protected]>wrote: > >> Hi Josh >> >> thanks for this tip, but my question is to do with you referring to >> collections of JAXB beans not being supported. >> I'd appreciate if you could send me an example of such a collection. >> Explicit collection have been supported for a while and I recall users >> confirming that it worked for them, so if there's some issue there lurking >> then I'd like to get it fixed :-) >> >> thanks, Sergey >> >> On Tue, Oct 5, 2010 at 7:24 PM, Josh Holtzman <[email protected] >> >wrote: >> >> > This part of the stack trace: >> > >> > Caused by: javax.ws.rs.WebApplicationException at >> > >> > >> org.apache.cxf.jaxrs.client.AbstractClient.reportNoMessageHandler(AbstractClient.java:487) >> > >> > looks like there's no message body writer. I've run into this kind of >> > problem when trying to return Collections, even collections of JAXB >> > elements, from JAX-RS endpoints. I usually solve it by wrapping the >> list >> > in >> > a root class, and passing the wrapper rather than the Collection, like >> > this: >> > >> > @XmlRootElement(name="deviceList") >> > public class DeviceList { >> > @XmlElement >> > protected List<Device> devices; >> > } >> > >> > Perhaps this might help in your case too, switching from >> > addDevice(List<Device> device) to addDevice(DeviceList deviceList). >> > >> > Josh >> > >> > On Tue, Oct 5, 2010 at 8:00 PM, oceanz <[email protected]> wrote: >> > >> > > >> > > I changed it to: >> > > @Path("user/site/plant/device/addDevice1") >> > > @POST >> > > @Produces("text/xml") >> > > @Consumes("multipart/form-data;type=text/xml") >> > > Device addDevice(List<Device> device); >> > > >> > > But it still doesn't work. >> > > Same exception:Caused by: javax.ws.rs.WebApplicationException >> > > at >> > > >> > > >> > >> org.apache.cxf.jaxrs.client.AbstractClient.reportNoMessageHandler(AbstractClient.java:487) >> > > at >> > > >> > > >> > >> org.apache.cxf.jaxrs.client.AbstractClient.writeBody(AbstractClient.java:401) >> > > at >> > > >> > > >> > >> org.apache.cxf.jaxrs.client.ClientProxyImpl$BodyWriter.handleMessage(ClientProxyImpl.java:514) >> > > ... 5 more >> > > >> > > Device is a JAXB Bean.: >> > > @Entity(name="device") >> > > @XmlRootElement(name="device") >> > > @XmlAccessorType(XmlAccessType.FIELD) >> > > public class Device extends DomainEntity { >> > > >> > > /** >> > > * >> > > */ >> > > private static final long serialVersionUID = 1L; >> > > >> > > public Device() {} >> > > >> > > >> > > @XmlAttribute(name="deviceName") >> > > private String deviceName; >> > > >> > > @XmlAttribute(name="deviceType") >> > > private String deviceType; >> > > >> > > @XmlAttribute(name="modelNumber") >> > > private String modelNumber; >> > > >> > > @XmlAttribute(name="serialNumber") >> > > private String serialNumber; >> > > .......... >> > > } >> > > >> > > Who do I need to do next? Desparate to get this working. >> > > Thanks for all your help. >> > > -- >> > > View this message in context: >> > > >> > >> http://cxf.547215.n5.nabble.com/Help-required-with-apache-cxf-multiparts-tp3199975p3200103.html >> > > Sent from the cxf-user mailing list archive at Nabble.com. >> > > >> > >> > >
