Hi

The solution is to add moxy as provider. I don't know if it has a
@Provider built in but if not  CXF relies on JAXBElementProvider for
JAXB serialization which can use a ContextResolver<JAXBContext> which
is a @Provider. This allows to keep default CXF provider
(writer/reader) and just change the context.

To register a provider either add it in getClasses() in your JAXRS
Application subclass or use openejb-jar.xml.

Romain Manni-Bucau
@rmannibucau |  Blog | Github | LinkedIn | Tomitriber


2016-03-30 11:27 GMT+02:00 Elgar <[email protected]>:
> I have clean TommEE Plume and Jdk 1.8. No other libs.
>
> I am trying to serve well formed xml fragment from String.
> Like in answer in this article.
> http://stackoverflow.com/questions/12428727/how-to-marshall-a-string-using-jaxb-that-sometimes-contains-xml-content-and-some
> And im getting error:
> JAXBException occurred : unable to marshal type "java.lang.String" as an
> element because it is missing an @XmlRootElement annotation. unable to
> marshal type "java.lang.String" as an element because it is missing an
> @XmlRootElement annotation.
>
> Response class is similar to Message class in example.
> So how to do it? Can i register MOXy for my jaxb or do i have to use jersey
> or something other?
>
>
> My service looks like that
>
> @Stateless
> @Path("/ap")
> public class SimpleGreeting {
>     @Path("/")
>     @POST
>     @Produces("text/xml")
>     public Response message3(String q) {
>             Response sfq = ap.getSfq(q);
>             return sfq;
>     }
> }

Reply via email to