Hi,

to give you a precise answer, you'd need to show us the Java code as well.

Still, within your Resources/Resource classes, do you initialize the
lists of resource/fileNames members upon object construction ?

I.e. how do you declare the property fielNames in class Resource ?

private List<String> filenames;

or

private List<String> filenames = new ArrayList<String>();

Cheers
Werner

On 16.12.2009 00:34, patrickh wrote:
> 
> Hi,
> 
> I am trying to unmarshall a xml which is produced by castor.
> I tried both having and not having mapping files and it all failed to
> unmarshal.
> Here is the xml:
> <?xml version="1.0" encoding="UTF-8"?>
> <resources>
>       <resource>
>               <resource-file>fake address 1</resource-file>
>               <description-name>spiderman</description-name>
>               <time-of-creation>2009-10-10</time-of-creation>
>               <owner>huangp</owner>
>               <comment>good one</comment>
>               <category>category 1</category>
>               <size>1g</size>
>               <file-names>spiderman1.rmvb</file-names>
>               <file-names>spiderman2.rmvb</file-names>
>       </resource>
>       <resource>
>               <resource-file>fake address 2</resource-file>
>               <description-name>superman</description-name>
>               <time-of-creation>2009-10-11</time-of-creation>
>               <owner>huangp</owner>
>               <comment>bad one</comment>
>               <category>category 1</category>
>               <size>200m</size>
>               <file-names>superman a.rmvb</file-names>
>               <file-names>superman b.rmvb</file-names>
>       </resource>
> </resources>
> 
> Here is the mapping:
> <class name="huangp.domain.Resource">
>       <map-to xml="resource" />
>       <field name="resourceFile" type="string" />
>       <field name="descriptionName" type="string" />
>       <field name="timeOfCreation" type="string" />
>       <field name="owner" type="string" />
>       <field name="comment" type="string" />
>       <field name="category" type="string" />
>       <field name="size" type="string" />
>       <field name="fileNames" type="string" collection="arraylist">
>               <bind-xml name="file-names" />
>       </field>
> </class>
> 
> <!-- mapping for class 'huangp.domain.Resources' -->
> <class name="huangp.domain.Resources">
>       <field name="resource" type="huangp.domain.Resource"
> collection="arraylist">
>               <bind-xml name="resource" />
>       </field>
> </class>
> 
> Exception trace:
> org.exolab.castor.xml.MarshalException: Nested error:
> java.lang.NullPointerException{File: [not available]; line: 11; column: 43}
> 
> Resources class only have one field which is a List<Resource>. Resource
> class has detailed fields and it contains another List<String> fileNames. I
> suspect it is to do with this nested list? Can anyone please help? BTW I
> can't access castor site since yesterday...
> 
> Big thank you.
> 

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to