27 June 2008

XmlBeans - ClassCastException

problem
while creating bean instance .it will throw
Exception in thread "main" java.lang.ClassCastException: com.javaorigin.xmlBean.SampleBean at com.javaorigin.xmlBean.SampleBean.SampleComplexBean.Factory.newInstance(Unknown Source)

Problem Root
This is java major and minor version problem .if you are using xmlbean 2.2.0 with jdk1.4.x
then it will happen

Solution
use latest jdk for compiling scemas (ex: use xmlBean2.2.0 with jdk1.5 )

1 comment:

mate tee said...

After using scomp (with the compile into jar option), I was able to successfully create the entire document w/o any ClassCastExceptions. I was using the xmlbean ant task previously (only generating the source and compiling everything later in the build script). I’m wondering if I was packaging all the necessary files – e.g., everything scomp produces with the “- out” option?