I’m trying to auto generate a mapping file using this program using Castor 1.3.2.
But here is the exception I get - java.lang.IllegalArgumentException: No enum const class org.exolab.castor.mapping.xml.types.BindXmlNodeType.element
This is a fairly basic test, what am I doing wrong?
public class CastorMapping {
public CastorMapping()
{
try
{
MappingTool tool = new MappingTool();
tool.setInternalContext(new org.castor.xml.BackwardCompatibilityContext());
tool.addClass(TestRequest.class);
OutputStream file = new FileOutputStream("gen_mapping.xml" );
Writer writer = new OutputStreamWriter(file);
tool.write(writer);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
public static void main(String[] args)
{
new CastorMapping();
}
}
Thanks!
I tried this myself and I believe you are doing everything correctly.
I browsed the castor source code and as far as I can tell, they broke the MappingTool somewhere between 1.3 and 1.3.2 when they redesigned BindXmlNodeType to be an enum class instead of a regular class. There is some code where they are looking for an BindXmlNodeType.element, but now that BindXmlNodeType is an enum they need to look up ELEMENT (caps). But I digress...
If you can afford to revert to castor 1.3, everything should work.
BTW - I tried to upgrade to 1.3.3-rc1 but Intellij could not resolve the maven dependencies. For example castor-xml in 1.3.3-rc1 now depends on Spring! It's possible that this bug is fixed in a later version, but I am not hopeful.