Hi,

looking at your class mapping for the OrderBean class (as given in the mapping below), I can see that you are declaring the required namespace, indeed (through the ns-uri attribute). At the same time you are specifying that this namespace is bound (exclusively) to a the prefix 'myOrder'.

Looking at your XML document below, it's quite obvious that you are NOT using the declared prefix, but a default namespace assignment

Clearly this would not work, right ?

Regards
Werner Guttmann

On 22.11.2010 16:52, kkrikor wrote:

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 ?


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

   http://xircles.codehaus.org/manage_email


Reply via email to