You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Philipp Schöpf <ph...@gmx.de> on 2006/08/03 19:32:00 UTC

java.lang.ClassCastException using TypeHelper

Hi,

I am encountering strange problems with the actual tuscany build (I got it from subversion this day) . This is what happens when I try to determine the type of my DataObject, calling myDataObject.getType():

java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EClassImpl
 at org.apache.tuscany.sdo.impl.DataObjectImpl.getType(DataObjectImpl.java:190)

I tried working around this using the Typehelper on my object, but this led to a similar error, calling TypeHelper.INSTANCE.getType(myDataObject.class);:

java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EClassImpl
 at org.apache.tuscany.sdo.helper.TypeHelperImpl.getType(TypeHelperImpl.java:98)


Btw, my DataObject class was generated from Xsd with the XSD2JavaGenerator. I am using the actual EMF 2.2.1 snapshot downloaded by maven during build. Btw, I never tried the same with the M1 build, should I?

Any hints?

Thanks in advance,
Philipp


Re: java.lang.ClassCastException using TypeHelper

Posted by Philipp Schöpf <ph...@gmx.de>.
Kelvin,

thanks for the hint, that exactly solved my problem!!

cheers,

Philipp
----- Original Message ----- 
From: "kelvin goodson" <ke...@thegoodsons.org.uk>
To: <tu...@ws.apache.org>; "Philipp Schöpf" <ph...@gmx.de>
Sent: Thursday, August 03, 2006 7:42 PM
Subject: Re: java.lang.ClassCastException using TypeHelper


Phillip,

In general DataObjectUtil.initRuntime() will be called by some use of SDO,
 but occasionally when using generated types, nothing triggers the call,
 and there are side effects, such as Type t =
((DataObject)generatedDO).getType(); fails with a class cast of EClass to
Type

in such situations you'll need to call the init directly,  this may
disappear with the -noEMF option

Regards, Kelvin.


On 03/08/06, Philipp Schöpf <ph...@gmx.de> wrote:
>
> Hi,
>
> I am encountering strange problems with the actual tuscany build (I got it
> from subversion this day) . This is what happens when I try to determine 
> the
> type of my DataObject, calling myDataObject.getType():
>
> java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EClassImpl
> at org.apache.tuscany.sdo.impl.DataObjectImpl.getType(DataObjectImpl.java
> :190)
>
> I tried working around this using the Typehelper on my object, but this
> led to a similar error, calling TypeHelper.INSTANCE.getType(
> myDataObject.class);:
>
> java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EClassImpl
> at org.apache.tuscany.sdo.helper.TypeHelperImpl.getType(
> TypeHelperImpl.java:98)
>
>
> Btw, my DataObject class was generated from Xsd with the
> XSD2JavaGenerator. I am using the actual EMF 2.2.1 snapshot downloaded by
> maven during build. Btw, I never tried the same with the M1 build, should 
> I?
>
> Any hints?
>
> Thanks in advance,
> Philipp
>
>
>


-- 
Best Regards
Kelvin Goodson



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: java.lang.ClassCastException using TypeHelper

Posted by kelvin goodson <ke...@thegoodsons.org.uk>.
Phillip,

In general DataObjectUtil.initRuntime() will be called by some use of SDO,
 but occasionally when using generated types, nothing triggers the call,
 and there are side effects, such as Type t =
((DataObject)generatedDO).getType(); fails with a class cast of EClass to
Type

in such situations you'll need to call the init directly,  this may
disappear with the -noEMF option

Regards, Kelvin.


On 03/08/06, Philipp Schöpf <ph...@gmx.de> wrote:
>
> Hi,
>
> I am encountering strange problems with the actual tuscany build (I got it
> from subversion this day) . This is what happens when I try to determine the
> type of my DataObject, calling myDataObject.getType():
>
> java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EClassImpl
> at org.apache.tuscany.sdo.impl.DataObjectImpl.getType(DataObjectImpl.java
> :190)
>
> I tried working around this using the Typehelper on my object, but this
> led to a similar error, calling TypeHelper.INSTANCE.getType(
> myDataObject.class);:
>
> java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EClassImpl
> at org.apache.tuscany.sdo.helper.TypeHelperImpl.getType(
> TypeHelperImpl.java:98)
>
>
> Btw, my DataObject class was generated from Xsd with the
> XSD2JavaGenerator. I am using the actual EMF 2.2.1 snapshot downloaded by
> maven during build. Btw, I never tried the same with the M1 build, should I?
>
> Any hints?
>
> Thanks in advance,
> Philipp
>
>
>


-- 
Best Regards
Kelvin Goodson

Re: java.lang.ClassCastException using TypeHelper

Posted by Frank Budinsky <fr...@ca.ibm.com>.
Philipp,

This error is usually means that the SDO runtime has not been initialized. 
Usually it happens as a side effect of accessing SDO helpers, but 
generated classes often have this problem. We're hopefully going to come 
up with a good way to avoid this in the future, but for now you can force 
initialization by calling DataObjectUtil.initRuntime() at the very start 
of your program.

Frank.

Philipp Schöpf <ph...@gmx.de> wrote on 08/03/2006 01:32:00 PM:

> Hi,
> 
> I am encountering strange problems with the actual tuscany build (I 
> got it from subversion this day) . This is what happens when I try 
> to determine the type of my DataObject, calling myDataObject.getType():
> 
> java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EClassImpl
>  at org.apache.tuscany.sdo.impl.DataObjectImpl.
> getType(DataObjectImpl.java:190)
> 
> I tried working around this using the Typehelper on my object, but 
> this led to a similar error, calling TypeHelper.INSTANCE.
> getType(myDataObject.class);:
> 
> java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EClassImpl
>  at org.apache.tuscany.sdo.helper.TypeHelperImpl.
> getType(TypeHelperImpl.java:98)
> 
> 
> Btw, my DataObject class was generated from Xsd with the 
> XSD2JavaGenerator. I am using the actual EMF 2.2.1 snapshot 
> downloaded by maven during build. Btw, I never tried the same with 
> the M1 build, should I?
> 
> Any hints?
> 
> Thanks in advance,
> Philipp
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org