users@jaxb.java.net

Re: Howto avoid 'a required object is missing' exception

From: Ed Mooney <Ed.Mooney_at_sun.com>
Date: Mon, 28 Jul 2003 11:29:27 -0400

Hi Jeroen,

Probably the safest thing to do is to make sure all the required
elements of your content tree are set before you try to marshal it. You
could also register a ValidationEventHandler that always returns true,
but then you could marshal an invalid instance.

Search subjects in the archive for "what object is missing".

Regards,
--
Ed Mooney         |Sun Microsystems, Inc.|Time flies like
Java Web Services |UBUR02-201            |an arrow, but
Ed.Mooney_at_Sun.COM |1 Network Drive       |fruit flies like
781-442-0459      |Burlington, MA  01803 |a banana. Groucho
Jeroen Breedveld wrote:
> Hi all,
>
> I'm getting the following exception when I marshall my user-type to a
> Node because the downloads type may not necessarily contain any data
> (yet). Can someone please tell me how do avoid this problem?
>
> javax.xml.bind.MarshalException
>  - with linked exception:
> [com.sun.xml.bind.serializer.AbortSerializationException: a required
> object is missing]
>
> My schema:
>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>       xmlns:userSpace="http://www.mycomp.com/user"
>       targetNamespace="http://www.mycomp.com/user">
>
>   <xsd:element name="user">
>     <xsd:complexType>
>       <xsd:sequence>
>         <xsd:element name="email" type="xsd:string"/>
>         <xsd:element name="password" type="xsd:string"/>
>         <xsd:element name="ip" type="xsd:string"/>
>         <xsd:element name="host" type="xsd:string"/>
>         <xsd:element name="name" type="xsd:string"/>
>         <xsd:element name="title" type="xsd:string"/>
>         <xsd:element name="companyName" type="xsd:string"/>
>         <xsd:element name="companyAddress" type="xsd:string"/>
>         <xsd:element name="companyCity" type="xsd:string"/>
>         <xsd:element name="companyState" type="xsd:string"/>
>         <xsd:element name="companyZip" type="xsd:string"/>
>         <xsd:element name="companyCountry" type="xsd:string"/>
>         <xsd:element name="companyTelephone" type="xsd:string"/>
>         <xsd:element name="companyFax" type="xsd:string"/>
>         <xsd:element name="companyURI" type="xsd:string"/>
>         <xsd:element name="comments" type="xsd:string"/>
>         <xsd:element name="industries" type="xsd:string"/>
>         <xsd:element name="relation" type="xsd:string"/>
>         <xsd:element name="size" type="xsd:string"/>
>         <xsd:element name="project" type="xsd:string"/>
>         <xsd:element name="timeframe" type="xsd:string"/>
>         <xsd:element name="os" type="xsd:string"/>
>         <xsd:element name="source" type="xsd:string"/>
>         <xsd:element name="updateNews" type="xsd:string"/>
>         <xsd:element name="downloads" type="userSpace:DownloadsType"/>
>       </xsd:sequence>
>     </xsd:complexType>
>   </xsd:element>
>
>   <xsd:complexType name="DownloadsType">
>     <xsd:sequence>
>       <xsd:element name="download">
>         <xsd:complexType>
>           <xsd:sequence>
>             <xsd:element name="file" type="xsd:string"/>
>             <xsd:element name="date" type="xsd:string"/>
>             <xsd:element name="ip" type="xsd:string"/>
>             <xsd:element name="host" type="xsd:string"/>
>           </xsd:sequence>
>         </xsd:complexType>
>       </xsd:element>
>     </xsd:sequence>
>   </xsd:complexType>
>
> </xsd:schema>
>
> Thanks and regards,
>
> Jeroen
>
> --
>
> X-Hive Corporation
> e-mail: jeroenb_at_x-hive.com
> phone: +31 10 2818080
> http://www.x-hive.com
>