users@jaxb.java.net

Howto avoid 'a required object is missing' exception

From: Jeroen Breedveld <jeroenb_at_x-hive.com>
Date: Mon, 28 Jul 2003 16:44:55 +0200

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