Jessica-

I don't have a lot of time this afternoon to dig into details, but looking at the NPE stacktrace, I wonder if defining types for all your fields would help? For example:

   <class name="com.ingenta.ics.ecommerce.api.item.Cost">
     <description>Mapping for Cost</description>
     <field name="costItems" collection="set"
            type="com.ingenta.ics.ecommerce.api.item.CostItem"
            container="false">
       <bind-xml name="costItems"/>
     </field>
     ...
   </class>

I'm not sure it is possible to do this for the Map (because it really has two types, the key and the value), but for all the sets, lists, and arrays, it might help (essentially what is the class inside the collection). Basically, if you look in XMLFieldDescriptorImpl, where you're getting there exception is the second line of:

   hash = 17 * _fieldName.hashCode();
   hash = hash * 17 * _fieldType.hashCode();

So I wonder if Castor is creating FieldDescriptors with null _fieldTypes and that throws the NPE.

Might not help anything, but it is a thought.

Stephen


Jessica Perry Hekman wrote:
On Tue, Dec 20, 2005 at 11:13:04AM -0500, Stephen Bash wrote:


The method I've been using more is nested class mappings. Basically you take your class mapping for org.exolab.castor.mapping.MapItem (from your first e-mail), and place it inside your bind-xml element like so:

  <field name="myHashMap" collection="map">
    <bind-xml name="hash-item">
      <class name="org.exolab.castor.mapping.MapItem">
        <field name="key" type="string">
          <bind-xml name="key" node="attribute" />
        </field>
        <field name="value" type="insert class here">
          <bind-xml name="value" />
        </field>
      </class>
    </bind-xml>
  </field>


Ahhh yes, this makes sense (sorry Werner, I couldn't get this far on my own :)

However of course things still break. Marshalling gives me:

[...]
    <hash-item key="_testPricingSub4">
        <value>
            <costItems>
                <costItem>
                    <currency>GBP</currency>
                    <amount>10.00</amount>
                    <exchangeRate>1</exchangeRate>
                    <type>price</type>
                </costItem>
                <costItem>
                    <currency>GBP</currency>
                    <amount>1.75</amount>
                    <exchangeRate>1</exchangeRate>
                    <type>tax</type>
                </costItem>
            </costItems>
            <preTaxAmount>10.00</preTaxAmount>
            <postTaxAmount>11.75</postTaxAmount>
            <taxRate>0.175</taxRate>
        </value>
    </hash-item>
[...]

but passing that back to unmarshalling gives me:

1) testQuotation(com.ingenta.ics.ecommerce.api.item.QuotationMarshallingTest)java.lang.NullPointerException at org.exolab.castor.xml.util.XMLFieldDescriptorImpl.hashCode(XMLFieldDescriptorImpl.java:416)
        at java.util.HashMap.hash(HashMap.java:261)

I seem to see this hashCode error a fair amount; the last time I managed to get a test case for it and reported it as a bug, but then found a workaround. I'll try to do the same this time, but so far this time I've been failing miserably at making my test cases break!

I'll attach the description file in case anyone can eyeball that and tell where the problem might be. I'm rapidly losing patience with trying to figure out where in this enormous system we have set things up poorly, so that Castor breaks, but I don't seem to have any option but to keep banging my head against it :P

Jessica




------------------------------------------------------------------------

-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to