users@jaxb.java.net

JAXB Marshalling Problem (JSR 286 RI)

From: Christian Raschka <chrisrasch_at_web.de>
Date: Sun, 16 Sep 2007 16:21:17 +0200

Hello,

I am working at the university of Jena implementing the reference
implementation of the JSR 286 (jcp.org/en/jsr/detail?id=286).

I have a problem marshalling an object:

The usual way to marshal an object (named "value") is like this:

JAXBContext jc = JAXBContext.newInstance(value.getClass());
Marshaller marshaller = jc.createMarshaller();
marshaller.marshal(value, out);

If this is a test program everythings works correctly (under the
assumption that the "value" class got the right annotations.)

But at our reference implementation we know nothing about value, except
it is the class with (hopefully) the right annotations (mainly
@XmlRootElement).

Exception:
Caused by: com.sun.istack.SAXException2: unable to marshal type
"de.xilma.pluto.Adress" as an element because it is missing an
@XmlRootElement annotation
        at
com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:226)
        at
com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:267)
        at
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:472)
        at
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:301)
        ... 35 more

(in this case, de.xilma.pluto.Adress got the right annotations ... they
are available at runtime (tested with debugger), but couldn't be
marshalled correct.

Is there a problem, because we use this in a servlet container? (e.g.
tomcat?)

Any comments are appreciated ...

Cheers,
Christian Raschka