We had the exactly the same problem. By reading the xml and we found that there was a confusion between a defined type and a defined element. JAXB generates two interfaces that are almost alike. The your code that generates the xml may have used the underlying type and not the element.
<xsd:element name="drawing">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="id" type="xsd:integer"/>
<xsd:element name="navn" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
This will generate the class Drawing and DrawingType. Check in your code that you are using the correct class. It must cohere with the xmlschema. If you hava used <element ref="drawing" minOccurs=0 maxOccurs=unbounded> you must use Drawing in your program that you write. If you have used <element name="mydrawing" type="drawing"> you must use DrawingType in your program. What makes it littlebit confusing is that one can have both definitions in the same XMLSchema.
------------------
Another thing that we discovered is that it is hard to use the exception returned from JAXB when there is a missing field (where minOccurs > 0). I would like to see the element that is missing. A workaround is allways to use minOccurs=0 in the xmlSchema, and drop that exception-functionallity.
Torstein
----- Original Message -----
From: "Ryan Shoemaker - JavaSoft East" <Ryan.Shoemaker_at_Sun.COM>
To: <JAXB-INTEREST_at_JAVA.SUN.COM>
Sent: Friday, November 08, 2002 5:26 PM
Subject: Re: Unmarshal exception..
> Enrico Zini wrote:
> >
> > I'm still not an expert in XML namespaces, so I can't tell if it's a bug
> > or it was a flawed use of namespaces, but the obscurity of the error
> > message can certainly qualify as a bug. It left me quite resourceless,
> > for a while: before removing the namespace directives, I've even tried
> > unmarshalling an XML file containing only a single valid root element,
> > and I still got the "Unexpected element" UnmarshalException.
>
>
> Enrico,
>
> JAXB is currently a beta quality product - we are actively fixing bugs and
> limitations. So far, none of our tests have exposed the problem you and Bill
> are describing. Please work with us to identify the cause of the issue so we
> can improve the quality of the final release version. If you can put together
> a simple test case that reproduces the problem, then send it in and we'll be
> happy to evaluate it. Until then, it will be impossible for us to fix the
> problem.
>
> Thanks,
>
> --Ryan