users@jaxb.java.net

com.sun.istack.SAXException2: unable to marshal ....

From: Wagle, Shriniwas <wagle_shriniwas_at_bah.com>
Date: Wed, 18 Jul 2007 18:11:21 -0400

Hi,

My WSDL operation takes in a fairly complex structure defined in an XML
Schema as a parameter.

I was able to compile the Schemas using JAXB 2.0.1.

While populating the JAXB generated objects, I thought I'd visually
inspect the generated XML.

In doing so, I am getting the exception shown below during marshalling:

Any thoughts on what could be causing this problem?

Thanks you

Exception in thread "main" javax.xml.bind.MarshalException
 - with linked exception:
[com.sun.istack.SAXException2: unable to marshal type
"abc.def.ghi.xsd.pqr.SomeClass" as an element because it is missing an
@XmlRootElement annotation]
        at
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:295
)
        at
com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:2
21)
        at
javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshaller
Impl.java:70)
        at
org.adlregistry.rim.TestSubmission.main(TestSubmission.java:101)
Caused by: com.sun.istack.SAXException2: unable to marshal type
"abc.def.ghi.xsd.pqr.SomeClass" as an element because it is missing an
@XmlRootElement annotation
        at
com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java
:225)
        at
com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInf
oImpl.java:274)
        at
com.sun.xml.bind.v2.runtime.property.ArrayReferenceNodeProperty.serializ
eListBody(ArrayReferenceNodeProperty.java:78)
        at
com.sun.xml.bind.v2.runtime.property.ArrayERProperty.serializeBody(Array
ERProperty.java:101)
        at
com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInf
oImpl.java:293)
        at
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.j
ava:619)
        at
com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serialize
Body(SingleElementNodeProperty.java:114)
        at
com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInf
oImpl.java:293)
        at
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.j
ava:619)
        at
com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serialize
Body(SingleElementNodeProperty.java:114)
        at
com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInf
oImpl.java:293)
        at
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.j
ava:619)
        at
com.sun.xml.bind.v2.runtime.property.ArrayElementNodeProperty.serializeI
tem(ArrayElementNodeProperty.java:29)
        at
com.sun.xml.bind.v2.runtime.property.ArrayElementProperty.serializeListB
ody(ArrayElementProperty.java:132)
        at
com.sun.xml.bind.v2.runtime.property.ArrayERProperty.serializeBody(Array
ERProperty.java:101)
        at
com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInf
oImpl.java:293)
        at
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.j
ava:619)
        at
com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serialize
Body(SingleElementNodeProperty.java:114)
        at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementB
eanInfoImpl.java:98)
        at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementB
eanInfoImpl.java:127)
        at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBea
nInfoImpl.java:244)
        at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBea
nInfoImpl.java:251)
        at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBea
nInfoImpl.java:33)
        at
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java
:461)
        at
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:292
)
        ... 3 more