Apologies for the odd subject line, but I have a rather odd problem! I'm
writing a Java object model for representing academic datasets, with a Dataset
class containing SortedSets of XAxis and YAxis objects, which contain Bins,
Points and so on.

I've been using Castor already (mainly version 0.9.9, but I just moved to using
1.0.4 to get collection="sortedset" to work) to map the structure of academic
papers (with a, yup, Paper class) and this has worked fine both for marshalling
and unmarshalling. Here's a snippet of the mapping file:


  <class name="cedar.hepdata.model.Paper">
    <field name="Title">
      <bind-xml name="title" node="element"/>
    </field>
    ...
    <field name="Datasets" type="cedar.hepdata.model.Dataset"
collection="sortedset">
      <bind-xml name="dataset" node="element"/>
    </field>
  </class>

  <class name="cedar.hepdata.model.Dataset">
    <field name="DatasetId">
      <bind-xml name="datasetId" node="attribute"/>
    </field>
    <field name="Header">
      <bind-xml name="header" node="attribute"/>
    </field>

    <field name="XAxes" type="cedar.hepdata.model.XAxis" collection="sortedset">
      <bind-xml name="xaxis" node="element"/>
    </field>
    <field name="YAxes" type="cedar.hepdata.model.YAxis" collection="sortedset">
      <bind-xml name="yaxis" node="element"/>
    </field>
  </class>


The problem is that I recently added mappings for the XAxis and YAxis classes
and I immediately get some sort of null reference error from Castor when I try
to run my unmarshalling test method (you'll recognize I'm using Maven 2):


Running cedar.hepdata.test.XMLTest
 INFO XMLTest:101 - Loading XML mapping
 INFO Mapping:201 - target/classes is not a URL, trying to convert it to a file 
URL
 INFO Mapping:246 - Loading mapping descriptors from hdom-xml-map.xml
 INFO XMLTest:104 - Reading XML file
 INFO XMLTest:106 - Making an unmarshaller
 INFO XMLTest:109 - Unmarshalling
ERROR XMLTest:114 - Problem with mapped XML unmarshalling:
ERROR XMLTest:115 - null{file: [not available]; line: 38; column: 9}
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.447 sec <<<
FAILURE!


I get the problem when I add this mapping element:


  <class name="cedar.hepdata.model.XAxis"> <!--
extends="cedar.hepdata.model.Axis"> -->
    <field name="XAxisId">
      <bind-xml name="xaxisId" node="attribute"/>
    </field>
  </class>


which is pretty minimal: XAxisId is just a java.lang.Integer and the get/set
methods with that name exist. You'll see that there's actually an inheritance
relationship here, but that doesn't affect this issue so I've commented it out)
Removing the field, so that the class element is empty makes the problem go
away, but isn't very useful! This is only a problem with unmarshalling: I can
add a much more complete mapping of XAxis and the marshalling is fine.
Interestingly, if I try to marshall a class structure and then unmarshall it
immediately, I get the same error on the unmarshalling side.

Can anyone help? I can't find any oddities in the Java code for these classes,
though I can post it if you want. All I can think is that there might be a
problem in Castor's unmarshalling when field or class names have two
consecutive capital letters... just a thought. Alternatively, is there some way
to get Castor to give me a more useful error printout or backtrace?

Thanks!
Andy

-- 
Andy Buckley: CEDAR @ IPPP, Durham
Work: www.cedar.ac.uk
www.insectnation.org

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

    http://xircles.codehaus.org/manage_email

Reply via email to