Hey guys, 

Yes i have seen and read all the posts regarding this exception but for some
reason cannot find the right answer so here's my scenario - 

XML looks like the following 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Order xmlns="http://www.company.org/ns/order/v3";>
    <Assignment>
        <Target>textHere</Target>
        <Other>...</Other>
    </Assignment>
</Order>

Mapping file looks like 

<mapping>

    <class name="org.company.OrderBean">
        <map-to xml="Order" ns-prefix="myOrder"
ns-uri="http://www.company.org/ns/rules/v3"/>
        
        <field name="MySets"
            type="org.company.MySetBean"
            collection="arraylist">
            <bind-xml name="Assignment"  />
        </field>
    </class>
    <class name="org.company.MySetBean">
        <map-to xml="Assignment" ns-prefix="myOrder"
ns-uri="http://www.company.org/ns/rules/v3"/>
       
       <field name="Target"
            type="org.company.TargetBean">
            <bind-xml name="Target"/>
        </field>
        
    </class>
    <class name="org.company.TargetBean" >
        <map-to ns-prefix="myOrder"/>
       <field name="Value" type="string">
            <bind-xml node="text"/>         
       </field>
     </class>
     ...
</mapping>

And finally the source code
private void loadMetadata() throws IOException {
        final String FILE_NAME = "/Users/Desktop/test.xml";
        FileInputStream is = null;
        try {
            is = new FileInputStream(FILE_NAME);
            MyObject object = (MyObject) this.castorMarshaller.unmarshal(new
StreamSource(is));
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (XmlMappingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            if (is != null) {
                is.close();
            }
        }

    }

And here's the exception - 

org.springframework.oxm.UnmarshallingFailureException: Castor unmarshalling
exception; nested exception is org.exolab.castor.xml.MarshalException:
unable to find FieldDescriptor for 'Target' in ClassDescriptor of
Assignment{File: [not available]; line: 4; column: 39}

The castor Marshaller is defined in spring as 

<bean id="castorMarshaller"
class="org.springframework.oxm.castor.CastorMarshaller" >
        <property name="mappingLocation"
value="classpath:properties/mappingMarshaller.xml" />
</bean>

As previous posts mention if I remove the namespace from the xml i can
successfully unmarshall. What am i missing ?
 
-- 
View this message in context: 
http://old.nabble.com/Unmarshalling-with-namespace-issue-tp30279912p30279912.html
Sent from the Castor - User mailing list archive at Nabble.com.


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

    http://xircles.codehaus.org/manage_email


Reply via email to