users@jaxb.java.net

Re: Unmarshal exception..

From: Ryan Shoemaker - JavaSoft East <Ryan.Shoemaker_at_sun.com>
Date: Thu, 07 Nov 2002 18:43:56 -0500

Hey Bill,

I wouldn't file a bug until we've figured out the cause of the exception, which is
impossible without having a look at the schema and your sample app. Have you tried
validating the content tree before marshalling it? I suspect that you're hitting a
case where your content tree is invalid, but not in a way that causes the marshaller
to complain. The JAXB spec doesn't require that the content tree be valid before
allowing the marshal operation to occur. It also doesn't require providers to be
capable of marshalling invalid content trees - some will fail on the first error,
others won't fail ever. In the case of the RI, we're somewhere in between those two
extremes.

Try validating the content tree before calling marshal and see if it catches anything.
If the RI doesn't report any validation events but still throws the UnmarshalException
on the round-trip, then it sounds like you may have found a bug. Feel free to send
in your schema and sample code and we'll take a look at it.

Thanks,

--Ryan


Bill Marcum wrote:
> I've written a schema, which cleanly compiles. If I instantiate one of these objects, use the 'set' methods to populate it, marshal it to a data stream, and then attempt to use the Unmarshaller to unmarshal it, I get an exception : javax.xml.bind.UnmarshalException: Unexpected element ....
>
> I'm hoping this is because I'm doing something wrong, but it seems more likely it's a bug in JAXB, right? That is, JAXB said the schema was valid, JAXB wrote the XML, and now JAXB says the XML is invalid.
>
> Should I be pouring over the JAXB documentation trying to figure out what I did wrong, or should I be submitting a bug report?
>