users@jaxb.java.net

Missing XmlRootElement annotation

From: Moravec Jan <Jan.Moravec_at_ips-ag.cz>
Date: Thu, 3 Aug 2006 12:24:35 +0200

Hi Koshuke,

No what I really mean is the @XmlRootElement annotation that seems to be required on a nested element. Sorry about the misleading subject, it was for the previous problem I encountered, but that got sorted. I changed the subject now to reflect the current problem.

When maschalling a content tree I am getting:

[findlibdeps] [com.sun.istack.SAXException2: unable to marshal type "com.yworks.xml.graphml.ShapeNodeType" as an element because it is missing an @XmlRootElement annotation]

The problematic element is a nested element, not the root element.

I will put together a simple test case so that you can reproduce this and I will submit it as an issue as you suggest.

Thank you,
Jan Moravec

-----Original Message-----
From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
Sent: Wednesday, August 02, 2006 5:50 PM
To: users_at_jaxb.dev.java.net
Subject: Re: No ObjectFactory with an @XmlElementDecl


Moravec Jan wrote:
> It does not look as if JAXB had problems locating the class, it is
> something more subtle. Why is the @XmlRootElement annotation required
> for a nested element that is not the root of the schema?

You mean @XmlElementDecl?

> Is there anything else I could try before I resort to stitching the XML instance "by hand"? Thank you for any tips.

This might be a bug in the JAXB RI. Can you file an issue on the issue
tracker, so that we can work on this problem?

>
> Best regards,
> Jan Moravec
>
> [findlibdeps] Creating a new JAXBContext with classes: {class org.graphdrawing.g
> raphml.xmlns.graphml.ObjectFactory, class com.yworks.xml.graphml.ObjectFactory}
> [findlibdeps] Jul 27, 2006 10:28:25 PM javax.xml.bind.ContextFinder find
> [findlibdeps] FINE: Trying to locate org/graphdrawing/graphml/xmlns/graphml/jaxb.properties
> [findlibdeps] Jul 27, 2006 10:28:25 PM javax.xml.bind.ContextFinder find
> [findlibdeps] FINE: not found
> [findlibdeps] Jul 27, 2006 10:28:25 PM javax.xml.bind.ContextFinder find
> [findlibdeps] FINE: Trying to locate com/yworks/xml/graphml/jaxb.properties
> [findlibdeps] Jul 27, 2006 10:28:25 PM javax.xml.bind.ContextFinder find
> [findlibdeps] FINE: not found
> [findlibdeps] Jul 27, 2006 10:28:25 PM javax.xml.bind.ContextFinder find
> [findlibdeps] FINE: Checking system property javax.xml.bind.JAXBContext
> [findlibdeps] Jul 27, 2006 10:28:25 PM javax.xml.bind.ContextFinder find
> [findlibdeps] FINE: not found
> [findlibdeps] Jul 27, 2006 10:28:25 PM javax.xml.bind.ContextFinder find
> [findlibdeps] FINE: Checking META-INF/services
> [findlibdeps] Jul 27, 2006 10:28:25 PM javax.xml.bind.ContextFinder find
> [findlibdeps] FINE: Reading jar:file:/c:/Java/e/lib/jaxb/jaxb-impl.jar!/META-INF
> /services/javax.xml.bind.JAXBContext
> [findlibdeps] Jul 27, 2006 10:28:25 PM javax.xml.bind.ContextFinder newInstance
> [findlibdeps] FINE: Trying to load com.sun.xml.bind.v2.ContextFactory
> [findlibdeps] Jul 27, 2006 10:28:25 PM javax.xml.bind.ContextFinder newInstance
> [findlibdeps] FINE: loaded com.sun.xml.bind.v2.ContextFactory from jar:file:/c:/
> Java/e/lib/jaxb/jaxb-impl.jar!/com/sun/xml/bind/v2/ContextFactory.class
> [findlibdeps] About to marshall object: javax.xml.bind.JAXBElement_at_a4488
> [findlibdeps] Object is a JAXBElement, name={http://graphml.graphdrawing.org/xmlns/graphml}graphml, type=class org.graphdrawing.graphml.xmlns.graphml.GraphmlType, scope=class javax.xml.bind.JAXBElement$GlobalScope, value=org.graphdrawing.graphml.xmlns.graphml.GraphmlType@19762f <mailto:value=org.graphdrawing.graphml.xmlns.graphml.GraphmlType@19762f>
> [findlibdeps] Error marschalling dependency graph: javax.xml.bind.JAXBElement_at_a4488
> [findlibdeps] javax.xml.bind.MarshalException
> [findlibdeps] - with linked exception:
> [findlibdeps] [com.sun.istack.SAXException2: unable to marshal type "com.yworks.xml.graphml.ShapeNodeType" as an element because it is missing an @XmlRootElement annotation]
> [findlibdeps] at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:295)
> [findlibdeps] at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:221)
> [findlibdeps] at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:77)
>
>
> -----Original Message-----
> From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
> Sent: Thu 7/27/2006 2:53 AM
> To: users_at_jaxb.dev.java.net
> Cc:
> Subject: Re: No ObjectFactory with an @XmlElementDecl
>
>
>
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net


--
Kohsuke Kawaguchi
Sun Microsystems kohsuke.kawaguchi_at_sun.com