You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Jian Li <ji...@yahoo.com.sg> on 2007/12/25 10:25:08 UTC

ClassCastException:XmlAnyTypeImpl

I hit the following class cast exceptions using xmlbeans-2.3.0
 
org.apache.xmlbeans.impl.values.XmlAnyTypeImpl
java.lang.ClassCastException: org.apache.xmlbeans.impl.values.XmlAnyTypeImpl 
 
 
it happened in 
 
target = (org.abc.def.XmlBeans.TELXmlBean)get_store().add_element_user(REFERENCE$0);
 
Basically, the function returns a object of  "XmlAnyTypeImpl", instead of of  "TELXmlBean"
 
In addition, any element that using the ST as data type will fail in xmlbeans  validation API calls, but the validation can pass in an XML editor, such as NetBean xml editor without any issue.
 
I have searched the mailing list and excluded that it is caused by mismatch of generated code with the xmlbeans version.
 
As I am quite new to xmlbeans, it would be very appreciated if you could offer any hint or solution , or confirm that it is a bug whatsoever.
 
Thanks.
 
 
 
 
 
 
Attached please find the xml schema
cd C:\xmlbeans-2.3.0\bin
scomp -mx 1024M -out CDAXmlBean.jar -d C:\cdaxml\classes -src C:\cdaxml\src -javasource 1.5 c:\xmlSchema\Schemas\CDA.xsd C:\xmlSchema\Schemas\cdaXml.xsdconfig
 
the code generation configuration file is :
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<xb:config xmlns:xb=
"http://xml.apache.org/xmlbeans/2004/02/xbean/config"
>
 <xb:namespace uri="##any">
  <xb:suffix>XmlBean</xb:suffix>
 </xb:namespace>
<xb:namespace  uri="urn:hl7-org:v3">
  <xb:package>org.abc.def.XmlBeans</xb:package>
</xb:namespace>
 
</xb:config>

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
The test case is:
 
 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
public class STTest extends TestCase{
    
   public void testST(){
    STXmlBean stxml = STXmlBean.Factory.newInstance();
    stxml.addNewReference();
   }
    
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


      __________________________________________________________________
Tired of visiting multiple sites for showtimes? 
Yahoo! Movies is all you need
http://sg.movies.yahoo.com

Re: ClassCastException:XmlAnyTypeImpl

Posted by Jacob Danner <ja...@gmail.com>.
Hi Jian,
Are you still having issues with this?
I haven't had issue using a similar xsdconfig with a different schema.
-jacobd

On Dec 25, 2007 1:25 AM, Jian Li <ji...@yahoo.com.sg> wrote:

> I hit the following class cast exceptions using xmlbeans-2.3.0
>
> org.apache.xmlbeans.impl.values.XmlAnyTypeImpl
> java.lang.ClassCastException:
> org.apache.xmlbeans.impl.values.XmlAnyTypeImpl
>
>
> it happened in
>
> target = (org.abc.def.XmlBeans.TELXmlBean
> )get_store().add_element_user(REFERENCE$0);
>
> Basically, the function returns a object of  "XmlAnyTypeImpl", instead of
> of  "TELXmlBean"
>
> In addition, any element that using the ST as data type will fail in
> xmlbeans  validation API calls, but the validation can pass in an XML
> editor, such as NetBean xml editor without any issue.
>
> I have searched the mailing list and excluded that it is caused by
> mismatch of generated code with the xmlbeans version.
>
> As I am quite new to xmlbeans, it would be very appreciated if you could
> offer any hint or solution , or confirm that it is a bug whatsoever.
>
> Thanks.
>
>
>
>
>
>
> Attached please find the xml schema
> cd C:\xmlbeans-2.3.0\bin
> scomp -mx 1024M -out CDAXmlBean.jar -d C:\cdaxml\classes -src
> C:\cdaxml\src -javasource 1.5 c:\xmlSchema\Schemas\CDA.xsd
> C:\xmlSchema\Schemas\cdaXml.xsdconfig
>
> the code generation configuration file is :
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> <xb:config xmlns:xb=
> "http://xml.apache.org/xmlbeans/2004/02/xbean/config"
> >
>  <xb:namespace uri="##any">
>   <xb:suffix>XmlBean</xb:suffix>
>  </xb:namespace>
> <xb:namespace  uri="urn:hl7-org:v3">
>   <xb:package>org.abc.def.XmlBeans</xb:package>
> </xb:namespace>
>
> </xb:config>
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> The test case is:
>
>
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> public class STTest extends TestCase{
>
>    public void testST(){
>     STXmlBean stxml = STXmlBean.Factory.newInstance();
>     stxml.addNewReference();
>    }
>
> }
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
> ------------------------------
>
> Search. browse and book<http://sg.rd.yahoo.com/spirit/fea/travel/*http://sg.travel.yahoo.com>your hotels and flights through Yahoo! Travel
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>



-- 
I'm competing in a Half-Ironman distance triathlon to raise money for the
fight against cancer!
Please help support my efforts by going to:
http://www.active.com/donate/tntwaak/jacobd