I am trying to add jax-rs annotations to an existing service implementation
generated by wsdltojava (wrapped style).  The POJO returned by my operation
is defined in a standalone XSD, and understandably doesn¹t have the
@XmlRootElement annotation (for the reasons described here
http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html).

My web service works fine, but my REST call dies with the error:
unable to marshal type "..." as an element because it is missing an
@XmlRootElement annotation

If I add the @XmlRootElement annotation to the POJO, it works fine, but from
the documentation it seems I shouldn¹t have to do this (and I don¹t want to,
as it is generated code).

In reading this bug: http://issues.apache.org/jira/browse/CXF-1650
It appears this was an issue and should be ³fixed² in the version I am using
(2.2 and trunk) but it¹s not clear if I am expected to configure something.

The documentation here:
http://cwiki.apache.org/CXF20DOC/jax-rs.html#JAX-RS-JAXBsupport states:
³Alternatively to using @XmlRootElement and Collection wrappers, one can
provide an Object factory which will tell JAXB how to
marshal a given type (in case of Collections - its template type).²

I have an ObjectFactory, generated by wsdl2java (and it looks correct), but
I¹m not sure how I am supposed to ³provide² it other than have it on the
classpath (as I do).  Could you expand upon what exactly one needs to do to
get this to work?

Thanks,
Scott

Scott Oster

Co-Director
Software Research Institute
Center for IT Innovations in Healthcare

Senior Researcher
Department of Biomedical Informatics

The Ohio State University
Phone: (614) 293-9590

Reply via email to