| From | Sent On | Attachments |
|---|
| Subject: | unable to marshal type XXX as an element because it is missing an @XmlRootElement annotation | |
|---|---|---|
| From: | Farrukh Najmi (farr...@wellfleetsoftware.com) | |
| Date: | Aug 15, 2007 1:43:11 pm | |
| List: | net.java.dev.metro.users | |
Refine Search
| From | Sent On | Attachments |
|---|---|---|
| Farrukh Najmi | Aug 15, 2007 1:43 pm | |
| Farrukh Najmi | Aug 15, 2007 7:12 pm |
| Subject: | unable to marshal type XXX as an element because it is missing an @XmlRootElement annotation | |
|---|---|---|
| From: | Farrukh Najmi (farr...@wellfleetsoftware.com) | |
| Date: | Aug 15, 2007 1:43:11 pm | |
| List: | net.java.dev.metro.users | |
Hi Kohsuke,
I am making my transition from JAXB 1.x to JAXB 2.x and just stumbled upon this error:
[com.sun.istack.SAXException2: unable to marshal type "XXX" as an element because it is missing an @XmlRootElement annotation]
You discuss this issue here: <http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html>
I am very confused by this current behavior of xjc generated binding.
The most common use case in XML Schema based on my experience is one where you define a type FooType and then one or more elements Foo based on that type.
In JAXB 1.x a class FooType was generated for the FooType and a class generated for each element Foo that used the type. That seemed to work quite nicely.
In JAXB 2.x I am very surprised to discover that nearly *all* my FooTypes can no longer be marshalled and instead I get the above error.
This seems very questionable behavior based on my experience.
Perhaps I am missing something? What was wrong with the old behavior? Am I the only one who finds this to be questionable? How do other folks deal with the issue?
Note when I try the suggested workaround of using:
<jaxb:globalBindings> <xjc:simple/> </jaxb:globalBindings>
I got all kinds of errors like:
[ERROR] Property "XXX" is already defined. Use <property> to resolve this conflict.
I thought I knew JAXB pretty well but now I feel like a total newbie.
Hope you can help me understand what is going on and how to get the familiar JAXB 1.x behavior or equivalent.
-- Regards, Farrukh

