Iain- I would guess the problem is that there is no type="float[]" or type="array" for the mapping file (since a 2D array is an array of arrays). I'm glad to hear Castor handles the field fine on introspection though :)
Two things you can try. If you need the mapping file for other fields, but not the 2D array, just specify the other fields in the mapping, and then place auto-complete="true" in the class element of the mapping file. Castor will then introspect the class as normal and according to your test case, work fine. This does require that any fields you DON'T want marshalled must be declared as transient (transient="true" in the field element). The other option is to declare that the field exists, but not define type or collection attributes for it. This is kind of sketchy, but there are times that Castor's introspection will find all the necessary information and do things right. I think both of these options are short-term solutions (more like work-arounds), and it would be beneficial if you could post an issue in Jira (http://jira.codehaus.org/browse/CASTOR) so that a long term solution can be created. It would be great if you have a test case you can attach. Stephen On 2/13/06, Iain Milne <[EMAIL PROTECTED]> wrote: > I have a simple TestClass consisting of a single field that is a 2D > array: > public float[][] array; > > (and a constructor to initialize the array). > > Using Castor's default class inspection stuff, an instance of this class > can be converted into xml. > > If I then attempt to unmarshal the object using the following, it works: > > Unmarshaller u = new Unmarshaller(TestClass.class); > TestClass test = (TestClass) u.unmarshal(new StringReader(xml)); > > > However, I need to use a mapping file. The entry for this class looks as > follows: > > <class name="TestClass"> > <field name="array" type="float" collection="array" direct="true"/> > </class> > > Using this mapping file, the same xml is written out by the Marshaller. > No problems so far. However, when attempting to unmarshal the object > using the mapping, it fails: > > Mapping mapping = new Mapping(); > mapping.loadMapping( "mapping.xml" ); > > Unmarshaller u = new Unmarshaller(mapping); > TestClass test = (TestClass) u.unmarshal(new StringReader(xml)); > > throwing a NullPointerException in > org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java: > 757) > > > This leads me to believe that Castor *can* successfully marshal and > unmarshal objects with 2D arrays, but either: > a) not when a mapping file is specified > b) not when the mapping file is wrong! > > Hopefully it's b) and fixable? Or maybe even a c) ? > > I don't have any other problems using mapping files, but for some reason > these 2D arrays are just not working. > > Thanks > > > ------------------------------------------------- > If you wish to unsubscribe from this list, please > send an empty message to the following address: > > [EMAIL PROTECTED] > ------------------------------------------------- > >

