Hi,

can I please ask you to create a Jira issue over at

http://jira.codehaus.org/browse/CASTOR

and attach a working unit test that we can use to reproduce the problem. It could well be that you might have been hit by a bug.

Thanks
Werner


On 03.05.2010 12:56, stavang wrote:

Hello,

I am struggling to include a mapping file in another mapping file, where
both are located in a jar. I have no problems loading a single mapping file
in a jar, but as soon as I try to link two mapping files I fail.

I have a "Container" class which contains a list of objects, of the type
"Stuff". "Stuff" has a list of objects of the type "SubStuff". All three
classes are defined in the mapping file "Container.mapping.xml".
I have also defined a sub-class of "Stuff" called "MyStuff". This class is
defined in the mapping file "MyStuff.mapping.xml". In "MyStuff.mapping.xml"
I refer to "Container.mapping.xml" with *Include
href="Container.mapping.xml"* and defines the MyStuff-class to be a
sub-class of "Stuff".
All files are in the same package/directory called container

Now I create Mapping objects of MyStuff and Container (MyStuff as an
example):
Mapping mapping = new Mapping(ClassLoader.getSystemClassLoader());
InputStream stream = MyStuff.class.getResourceAsStream(fileName);
InputSource source = new InputSource(stream);
mapping.loadMapping(source);

I add both mapping objects in an XMLContext and try to unmarshal an xml-file
which contains one MyStuff-element with one SubStuff-element. I get the
following error in log:
3x org.exolab.castor.xml.MarshalException: N:\Test\Container.mapping.xml
(Das System kann die angegebene Datei nicht finden) (translated: cannot find
file)

And the following exception is thrown:
Exception in thread "main" org.exolab.castor.xml.MarshalException: unable to
find FieldDescriptor for 'SubStuff' in ClassDescriptor of MyStuff{File: [not
available]; line: 3; column: 13}
Caused by: org.xml.sax.SAXException: unable to find FieldDescriptor for
'SubStuff' in ClassDescriptor of MyStuff
Caused by: org.xml.sax.SAXException: unable to find FieldDescriptor for
'SubStuff' in ClassDescriptor of MyStuff


If I copy the Container.mapping.xml to the root of the working-directory, I
everything works perfectly. How can I refer the Container.mapping.xml file
correctly in MyStuff.mapping.xml?

I have included the files of my test-case:
http://old.nabble.com/file/p28433751/Container.java Container.java
http://old.nabble.com/file/p28433751/Container.mapping.xml
Container.mapping.xml
http://old.nabble.com/file/p28433751/MyStuff.java MyStuff.java
http://old.nabble.com/file/p28433751/MyStuff.mapping.xml MyStuff.mapping.xml
http://old.nabble.com/file/p28433751/Stuff.java Stuff.java
http://old.nabble.com/file/p28433751/SubStuff.java SubStuff.java
http://old.nabble.com/file/p28433751/complete_stacktrace.txt
complete_stacktrace.txt

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

   http://xircles.codehaus.org/manage_email


Reply via email to