http://www.mail-archive.com/[email protected]/msg01049.html
http://www.mail-archive.com/[email protected]/msg02437.html

I am facing similar issue that is described in the above two threads. I 
debugged this issue and this is what I found.

When Castor is generating source code for the complex types in 
org.exolab.castor.builder.SourceGenerator.java, it calls getComplexTypes on 
org.exolab.castor.xml.schema.Schema. However the list of complex types that are 
returned are not in any particular order. In my case the order in which these 
complex types were generated was such that, Complex type A is processed first 
which contains complex type B. Type "B" is declared as abstract. However source 
code for type "B" is not yet generated, so as far as castor code is concerned 
it doesn't know this is a abstract type.

Now when it generates the class descriptor class for type "A"  and creates the 
XMLFieldHandler inner class  and implements the newInstance method, it doesn't 
know if "B" is abstract or not, and by default it is false. As a result "B" is 
getting instantiated.

Once the class "B" is created, it is correctly identified as abstract, and the 
class descriptor of "A" fails to compile.

Currently I fixed this issue by having code such that complex types are 
processed in a predictable order.

Any pointers on how to fix this correctly? Isn't it a good idea to process the 
complex types in the order that was defined in the schema?

Thanks,
-Praveen

Reply via email to