This is a Xerces 2.0 bug. Either use the Xerces (1.4.0) that comes with
Castor, or upgrade to 2.0.1

--Keith

"Mark A. Sellers" wrote:
> 
> Trying to learn how to use Castor to marshall an object to XML.  Here's the
> exception:
> 
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
>         at
> org.apache.xerces.util.NamespaceSupport.popContext(NamespaceSupport.j
> ava:218)
>         at
> org.apache.xml.serialize.XMLSerializer.endElementIO(XMLSerializer.jav
> a:400)
>         at
> org.apache.xml.serialize.XMLSerializer.endElement(XMLSerializer.java:
> 387)
>         at
> org.apache.xml.serialize.XMLSerializer.endElement(XMLSerializer.java:
> 533)
>         at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:978)
>         at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:540)
>         at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:460)
>         at rm.castor.Castor.main(Castor.java:51)
> 
> Sample code:
> 
>     TestObject cc = new TestObject("Ryan 'Mad Dog' Madden");
>     cc.setDateOfBirth(new Date());
> 
> try {
>   FileWriter writer = new FileWriter("C:\\Castor\\cc.xml");
>   Marshaller mm = new Marshaller(writer);
>   mm.setNamespaceMapping("-//EXOLAB/Castor Object Mapping Schema Version
> 1.0//EN","http://castor.exolab.org/mapping.xsd";);
>   mm.setMarshalAsDocument(true);
>   mm.setValidation(false);
>   mm.setNSPrefixAtRoot(true);
>   mm.marshal(cc, writer);
> 
> } catch (java.io.IOException ioe) {
> } catch ( org.exolab.castor.xml.MarshalException me ) {
> } catch ( org.exolab.castor.xml.ValidationException ve ) {
> }
> 
> TestObject class:
> import java.util.Date;
> 
> /**
>  * An simple person class
>  */
> public class TestObject implements java.io.Serializable {
> 
>    /**
>      * The name of the person
>      */
>    private String name = null;
> 
>    /**
>      * The Date of birth
>      */
>    private Date dob = null;
> 
>    /**
>      * Creates a Person with no name
>      */
>    public TestObject() {
>       super();
>    }
> 
>    /**
>      * Creates a Person with the given name
>      */
>    public TestObject(String name) {
>       this.name  = name;
>    }
> 
>    /**
>      * @return date of birth of the person
>      */
>    public Date getDateOfBirth() {
>       return dob;
>    }
> 
>    /**
>      * @return name of the person
>      */
>    public String getName() {
>       return name;
>    }
> 
>    /**
>      * Sets the date of birth of the person
>      * @param name the name of the person
>      */
>    public void setDateOfBirth(Date dob) {
>       this.dob = dob;
>    }
> 
>    /**
>      * Sets the name of the person
>      * @param name the name of the person
>      */
>    public void setName(String name) {
>       this.name = name;
>    }
> }
> 
> Mark A. Sellers
> Worldcom, Inc.
> Resource Manager Development
> Dept/Loc:1780/117
> Phone:719-535-6699  Vnet:622-6699
> Fax:719-535-1488
> http://www.worldcom.com
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to