Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] ClassCastException retrieving model
[Teneo] ClassCastException retrieving model [message #81193] Wed, 25 April 2007 16:38 Go to next message
Alain Picard is currently offline Alain PicardFriend
Messages: 235
Registered: July 2009
Senior Member
I am getting acquainted with Teneo and going through the library editor
example (after successfully doing the Tutorial1 part). I have been able
to start the wizard on an empty database and to create a library with a
book and author.

When I restart back from scratch, it attempts to load the content of the
db and fails with the following:
java.lang.ClassCastException: org.eclipse.example.library.BookCategory
cannot be cast to org.eclipse.example.library.BookCategory
at org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
at
org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
at
org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
at
org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
at
org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
at
org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
.....etc

This gives me the idea that I might be dealing with a classloader
problem, since my Hibernate jars are in a different bundle. I have it's
buddy policy set to registered and all of the library projects have
Eclipse-RegisterBuddy: Shared_JARs (the bundle containing Hibernate).

Does anyone has seen this before and have any clue how to fix it?

Thanks
Alain
Re: [Teneo] ClassCastException retrieving model [message #81208 is a reply to message #81193] Wed, 25 April 2007 18:35 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Alain,
Can you try setting the buddy policy to dependent? Although it is less precise (classloading can
take more time) it is the safest to try.

gr. Martin

Alain Picard wrote:
> I am getting acquainted with Teneo and going through the library editor
> example (after successfully doing the Tutorial1 part). I have been able
> to start the wizard on an empty database and to create a library with a
> book and author.
>
> When I restart back from scratch, it attempts to load the content of the
> db and fails with the following:
> java.lang.ClassCastException: org.eclipse.example.library.BookCategory
> cannot be cast to org.eclipse.example.library.BookCategory
> at org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
> at
> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>
> at
> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>
> at
> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>
> at
> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
> at
> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>
> .....etc
>
> This gives me the idea that I might be dealing with a classloader
> problem, since my Hibernate jars are in a different bundle. I have it's
> buddy policy set to registered and all of the library projects have
> Eclipse-RegisterBuddy: Shared_JARs (the bundle containing Hibernate).
>
> Does anyone has seen this before and have any clue how to fix it?
>
> Thanks
> Alain


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] ClassCastException retrieving model [message #81223 is a reply to message #81208] Wed, 25 April 2007 19:48 Go to previous messageGo to next message
Alain Picard is currently offline Alain PicardFriend
Messages: 235
Registered: July 2009
Senior Member
Martin,

I just made the changes and did a clean build, started with -clean, but
to no avail.

Any other idea?

Alain

Martin Taal wrote:
> Hi Alain,
> Can you try setting the buddy policy to dependent? Although it is less
> precise (classloading can take more time) it is the safest to try.
>
> gr. Martin
>
> Alain Picard wrote:
>> I am getting acquainted with Teneo and going through the library
>> editor example (after successfully doing the Tutorial1 part). I have
>> been able to start the wizard on an empty database and to create a
>> library with a book and author.
>>
>> When I restart back from scratch, it attempts to load the content of
>> the db and fails with the following:
>> java.lang.ClassCastException: org.eclipse.example.library.BookCategory
>> cannot be cast to org.eclipse.example.library.BookCategory
>> at org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
>> at
>> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>>
>> at
>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>>
>> at
>> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>>
>> at
>> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
>> at
>> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>>
>> .....etc
>>
>> This gives me the idea that I might be dealing with a classloader
>> problem, since my Hibernate jars are in a different bundle. I have
>> it's buddy policy set to registered and all of the library projects
>> have Eclipse-RegisterBuddy: Shared_JARs (the bundle containing
>> Hibernate).
>>
>> Does anyone has seen this before and have any clue how to fix it?
>>
>> Thanks
>> Alain
>
>
Re: [Teneo] ClassCastException retrieving model [message #81237 is a reply to message #81223] Wed, 25 April 2007 20:30 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Alain,
I am a bit mistified myself also, when you set a breakpoint here: BookImpl.eSet(BookImpl.java:309),
what is the class of the object you get and what is the class instance to which the cast is tried?

Which version of Teneo are you using?
Can you post/send me the hbm mapping? (you can get it by doing dataStore.getMappingXML())

gr. Martin

Alain Picard wrote:
> Martin,
>
> I just made the changes and did a clean build, started with -clean, but
> to no avail.
>
> Any other idea?
>
> Alain
>
> Martin Taal wrote:
>> Hi Alain,
>> Can you try setting the buddy policy to dependent? Although it is less
>> precise (classloading can take more time) it is the safest to try.
>>
>> gr. Martin
>>
>> Alain Picard wrote:
>>> I am getting acquainted with Teneo and going through the library
>>> editor example (after successfully doing the Tutorial1 part). I have
>>> been able to start the wizard on an empty database and to create a
>>> library with a book and author.
>>>
>>> When I restart back from scratch, it attempts to load the content of
>>> the db and fails with the following:
>>> java.lang.ClassCastException:
>>> org.eclipse.example.library.BookCategory cannot be cast to
>>> org.eclipse.example.library.BookCategory
>>> at org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
>>> at
>>> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>>>
>>> at
>>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>>>
>>> at
>>> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>>>
>>> at
>>> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
>>>
>>> at
>>> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>>>
>>> .....etc
>>>
>>> This gives me the idea that I might be dealing with a classloader
>>> problem, since my Hibernate jars are in a different bundle. I have
>>> it's buddy policy set to registered and all of the library projects
>>> have Eclipse-RegisterBuddy: Shared_JARs (the bundle containing
>>> Hibernate).
>>>
>>> Does anyone has seen this before and have any clue how to fix it?
>>>
>>> Thanks
>>> Alain
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] ClassCastException retrieving model [message #81282 is a reply to message #81237] Wed, 25 April 2007 22:19 Go to previous messageGo to next message
Alain Picard is currently offline Alain PicardFriend
Messages: 235
Registered: July 2009
Senior Member
Martin,

I get a org.eclipse.example.library.BookCategory and it is being cast to
BookCategory as the error mentioned:
java.lang.ClassCastException: org.eclipse.example.library.BookCategory
cannot be cast to org.eclipse.example.library.BookCategory

I am using the latest version of Teneo (0.8
emft-teneo-SDK-I200704230019) with EMF (emf-sdo-xsd-SDK-2.3.0M6) under
Eclipse 3.3M6

I am trying to get some trace info to get the class loader tree, but I
am still fighting that battle.

Thanks for your help.
Alain


Here is the mapping info:
<hibernate-mapping>
<class name="org.eclipse.example.library.impl.BookImpl"
entity-name="Book" abstract="false" lazy="false"
discriminator-value="Book" table="`book`">
<meta attribute="eclassName">Book</meta>
<meta
attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
<id type="long" name="e_id" column="e_id"
access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
<meta attribute="syntheticId">true</meta>
<generator class="native"/>
</id>
<discriminator column="`dtype`" type="string"/>
<version name="e_version" column="e_version"
access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
<meta attribute="syntheticVersion">true</meta>
</version>
<property name="title" lazy="false" insert="true" update="true"
not-null="false" unique="false" type="java.lang.String">
<column not-null="false" unique="false" name="`title`"/>
</property>
<property name="pages" lazy="false" insert="true" update="true"
not-null="false" unique="false" type="int">
<column not-null="false" unique="false" name="`pages`"/>
</property>
<property name="category" lazy="false" not-null="false" insert="true"
update="true" unique="false">
<column not-null="false" unique="false" name="`category`"/>
<type name="org.eclipse.emf.teneo.hibernate.mapping.ENumUserType" >
<param name="enumClass">org.eclipse.example.library.BookCategory</param >
</type>
</property>
<many-to-one name="author" entity-name="Writer"
cascade="merge,persist,save-update,lock,refresh" lazy="false"
insert="false" update="false" not-null="false">
<column not-null="false" unique="false" name="`book_author_e_id`"/>
</many-to-one>
</class>
<class name="org.eclipse.example.library.impl.LibraryImpl"
entity-name="Library" abstract="false" lazy="false"
discriminator-value="Library" table="`library`">
<meta attribute="eclassName">Library</meta>
<meta
attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
<id type="long" name="e_id" column="e_id"
access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
<meta attribute="syntheticId">true</meta>
<generator class="native"/>
</id>
<discriminator column="`dtype`" type="string"/>
<version name="e_version" column="e_version"
access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
<meta attribute="syntheticVersion">true</meta>
</version>
<property name="name" lazy="false" insert="true" update="true"
not-null="false" unique="false" type="java.lang.String">
<column not-null="false" unique="false" name="`name`"/>
</property>
<list name="writers" lazy="true" cascade="all,delete-orphan">
<key update="true">
<column name="`library_writers_e_id`" not-null="false" unique="false"/>
</key>
<list-index column="`library_writers_idx`"/>
<one-to-many entity-name="Writer"/>
</list>
<list name="books" lazy="true" cascade="all,delete-orphan">
<key update="true">
<column name="`library_books_e_id`" not-null="false" unique="false"/>
</key>
<list-index column="`library_books_idx`"/>
<one-to-many entity-name="Book"/>
</list>
</class>
<class name="org.eclipse.example.library.impl.WriterImpl"
entity-name="Writer" abstract="false" lazy="false"
discriminator-value="Writer" table="`writer`">
<meta attribute="eclassName">Writer</meta>
<meta
attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
<id type="long" name="e_id" column="e_id"
access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
<meta attribute="syntheticId">true</meta>
<generator class="native"/>
</id>
<discriminator column="`dtype`" type="string"/>
<version name="e_version" column="e_version"
access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
<meta attribute="syntheticVersion">true</meta>
</version>
<property name="name" lazy="false" insert="true" update="true"
not-null="false" unique="false" type="java.lang.String">
<column not-null="false" unique="false" name="`name`"/>
</property>
<list name="books" lazy="true"
cascade="merge,persist,save-update,lock,refresh">
<key update="true">
<column name="`book_author_e_id`" not-null="false" unique="false"/>
</key>
<list-index column="`writer_books_idx`"/>
<one-to-many entity-name="Book"/>
</list>
</class>
</hibernate-mapping>


Martin Taal wrote:
> Alain,
> I am a bit mistified myself also, when you set a breakpoint here:
> BookImpl.eSet(BookImpl.java:309),
> what is the class of the object you get and what is the class instance
> to which the cast is tried?
>
> Which version of Teneo are you using?
> Can you post/send me the hbm mapping? (you can get it by doing
> dataStore.getMappingXML())
>
> gr. Martin
>
> Alain Picard wrote:
>> Martin,
>>
>> I just made the changes and did a clean build, started with -clean,
>> but to no avail.
>>
>> Any other idea?
>>
>> Alain
>>
>> Martin Taal wrote:
>>> Hi Alain,
>>> Can you try setting the buddy policy to dependent? Although it is
>>> less precise (classloading can take more time) it is the safest to try.
>>>
>>> gr. Martin
>>>
>>> Alain Picard wrote:
>>>> I am getting acquainted with Teneo and going through the library
>>>> editor example (after successfully doing the Tutorial1 part). I have
>>>> been able to start the wizard on an empty database and to create a
>>>> library with a book and author.
>>>>
>>>> When I restart back from scratch, it attempts to load the content of
>>>> the db and fails with the following:
>>>> java.lang.ClassCastException:
>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>> org.eclipse.example.library.BookCategory
>>>> at
>>>> org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>>>>
>>>> at
>>>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>>>>
>>>> at
>>>> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>>>>
>>>> at
>>>> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
>>>>
>>>> at
>>>> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>>>>
>>>> .....etc
>>>>
>>>> This gives me the idea that I might be dealing with a classloader
>>>> problem, since my Hibernate jars are in a different bundle. I have
>>>> it's buddy policy set to registered and all of the library projects
>>>> have Eclipse-RegisterBuddy: Shared_JARs (the bundle containing
>>>> Hibernate).
>>>>
>>>> Does anyone has seen this before and have any clue how to fix it?
>>>>
>>>> Thanks
>>>> Alain
>>>
>>>
>
>
Re: [Teneo] ClassCastException retrieving model [message #81298 is a reply to message #81282] Thu, 26 April 2007 04:48 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Alain,
I am not sure why this does not work but I can give you some more background information for you to
look at. At your breakpoint in the BookImpl.eSet you can get the classloader from both the
BookCategory class used for the cast as well as the classloader (getClassLoader() method on the
class itself). The same can be done for the class of the passed object. In the debugger you can try
to walk through the classloader hierarchy to see if the two classloaders are related.

The (BookCategory) class of the passed object in the eSet is loaded in the EnumUserType class in the
setParameterValues method. This is done when you initialize the datastore. As a default teneo uses
the ContextClassLoaderStrategy (see org.eclipse.emf.teneo.classloader) which uses the following to
load the class:
Thread.currentThread().getContextClassLoader()

I do not know how/when the second classloader (which reads its own BookCategory) comes into play. To
analyse this it could help to put a static initializer block in the BookCategory class with a
breakpoint (or print the stack trace) and then see when this is executed (twice).

It seems that the initialization of the datastore uses a classloader which is not related to the
classloader which later reads the library model again for your plugins.

gr. Martin

Alain Picard wrote:
> Martin,
>
> I get a org.eclipse.example.library.BookCategory and it is being cast to
> BookCategory as the error mentioned:
> java.lang.ClassCastException: org.eclipse.example.library.BookCategory
> cannot be cast to org.eclipse.example.library.BookCategory
>
> I am using the latest version of Teneo (0.8
> emft-teneo-SDK-I200704230019) with EMF (emf-sdo-xsd-SDK-2.3.0M6) under
> Eclipse 3.3M6
>
> I am trying to get some trace info to get the class loader tree, but I
> am still fighting that battle.
>
> Thanks for your help.
> Alain
>
>
> Here is the mapping info:
> <hibernate-mapping>
> <class name="org.eclipse.example.library.impl.BookImpl"
> entity-name="Book" abstract="false" lazy="false"
> discriminator-value="Book" table="`book`">
> <meta attribute="eclassName">Book</meta>
> <meta
> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
> <id type="long" name="e_id" column="e_id"
> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>
> <meta attribute="syntheticId">true</meta>
> <generator class="native"/>
> </id>
> <discriminator column="`dtype`" type="string"/>
> <version name="e_version" column="e_version"
> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>
> <meta attribute="syntheticVersion">true</meta>
> </version>
> <property name="title" lazy="false" insert="true" update="true"
> not-null="false" unique="false" type="java.lang.String">
> <column not-null="false" unique="false" name="`title`"/>
> </property>
> <property name="pages" lazy="false" insert="true" update="true"
> not-null="false" unique="false" type="int">
> <column not-null="false" unique="false" name="`pages`"/>
> </property>
> <property name="category" lazy="false" not-null="false"
> insert="true" update="true" unique="false">
> <column not-null="false" unique="false" name="`category`"/>
> <type
> name="org.eclipse.emf.teneo.hibernate.mapping.ENumUserType" >
> <param
> name="enumClass">org.eclipse.example.library.BookCategory</param >
> </type>
> </property>
> <many-to-one name="author" entity-name="Writer"
> cascade="merge,persist,save-update,lock,refresh" lazy="false"
> insert="false" update="false" not-null="false">
> <column not-null="false" unique="false"
> name="`book_author_e_id`"/>
> </many-to-one>
> </class>
> <class name="org.eclipse.example.library.impl.LibraryImpl"
> entity-name="Library" abstract="false" lazy="false"
> discriminator-value="Library" table="`library`">
> <meta attribute="eclassName">Library</meta>
> <meta
> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
> <id type="long" name="e_id" column="e_id"
> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>
> <meta attribute="syntheticId">true</meta>
> <generator class="native"/>
> </id>
> <discriminator column="`dtype`" type="string"/>
> <version name="e_version" column="e_version"
> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>
> <meta attribute="syntheticVersion">true</meta>
> </version>
> <property name="name" lazy="false" insert="true" update="true"
> not-null="false" unique="false" type="java.lang.String">
> <column not-null="false" unique="false" name="`name`"/>
> </property>
> <list name="writers" lazy="true" cascade="all,delete-orphan">
> <key update="true">
> <column name="`library_writers_e_id`" not-null="false"
> unique="false"/>
> </key>
> <list-index column="`library_writers_idx`"/>
> <one-to-many entity-name="Writer"/>
> </list>
> <list name="books" lazy="true" cascade="all,delete-orphan">
> <key update="true">
> <column name="`library_books_e_id`" not-null="false"
> unique="false"/>
> </key>
> <list-index column="`library_books_idx`"/>
> <one-to-many entity-name="Book"/>
> </list>
> </class>
> <class name="org.eclipse.example.library.impl.WriterImpl"
> entity-name="Writer" abstract="false" lazy="false"
> discriminator-value="Writer" table="`writer`">
> <meta attribute="eclassName">Writer</meta>
> <meta
> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
> <id type="long" name="e_id" column="e_id"
> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>
> <meta attribute="syntheticId">true</meta>
> <generator class="native"/>
> </id>
> <discriminator column="`dtype`" type="string"/>
> <version name="e_version" column="e_version"
> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>
> <meta attribute="syntheticVersion">true</meta>
> </version>
> <property name="name" lazy="false" insert="true" update="true"
> not-null="false" unique="false" type="java.lang.String">
> <column not-null="false" unique="false" name="`name`"/>
> </property>
> <list name="books" lazy="true"
> cascade="merge,persist,save-update,lock,refresh">
> <key update="true">
> <column name="`book_author_e_id`" not-null="false"
> unique="false"/>
> </key>
> <list-index column="`writer_books_idx`"/>
> <one-to-many entity-name="Book"/>
> </list>
> </class>
> </hibernate-mapping>
>
>
> Martin Taal wrote:
>> Alain,
>> I am a bit mistified myself also, when you set a breakpoint here:
>> BookImpl.eSet(BookImpl.java:309),
>> what is the class of the object you get and what is the class instance
>> to which the cast is tried?
>>
>> Which version of Teneo are you using?
>> Can you post/send me the hbm mapping? (you can get it by doing
>> dataStore.getMappingXML())
>>
>> gr. Martin
>>
>> Alain Picard wrote:
>>> Martin,
>>>
>>> I just made the changes and did a clean build, started with -clean,
>>> but to no avail.
>>>
>>> Any other idea?
>>>
>>> Alain
>>>
>>> Martin Taal wrote:
>>>> Hi Alain,
>>>> Can you try setting the buddy policy to dependent? Although it is
>>>> less precise (classloading can take more time) it is the safest to try.
>>>>
>>>> gr. Martin
>>>>
>>>> Alain Picard wrote:
>>>>> I am getting acquainted with Teneo and going through the library
>>>>> editor example (after successfully doing the Tutorial1 part). I
>>>>> have been able to start the wizard on an empty database and to
>>>>> create a library with a book and author.
>>>>>
>>>>> When I restart back from scratch, it attempts to load the content
>>>>> of the db and fails with the following:
>>>>> java.lang.ClassCastException:
>>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>>> org.eclipse.example.library.BookCategory
>>>>> at
>>>>> org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>>>>>
>>>>> at
>>>>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>>>>>
>>>>> at
>>>>> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>>>>>
>>>>> at
>>>>> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
>>>>>
>>>>> at
>>>>> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>>>>>
>>>>> .....etc
>>>>>
>>>>> This gives me the idea that I might be dealing with a classloader
>>>>> problem, since my Hibernate jars are in a different bundle. I have
>>>>> it's buddy policy set to registered and all of the library projects
>>>>> have Eclipse-RegisterBuddy: Shared_JARs (the bundle containing
>>>>> Hibernate).
>>>>>
>>>>> Does anyone has seen this before and have any clue how to fix it?
>>>>>
>>>>> Thanks
>>>>> Alain
>>>>
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] ClassCastException retrieving model [message #81343 is a reply to message #81298] Thu, 26 April 2007 20:37 Go to previous messageGo to next message
Alain Picard is currently offline Alain PicardFriend
Messages: 235
Registered: July 2009
Senior Member
Martin,

Here is what I am getting (in order):
In static init of BookCategory.
CL:org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea

In ENumUserType with enumClassName of:
org.eclipse.example.library.BookCategory

then it goes to get the classForName:
Thread.getContextClassLoader() line: 1314 [local variables unavailable]
ContextClassLoaderStrategy.getClassLoader() line: 32
ClassLoaderResolver.getClassLoader() line: 59
ClassLoaderResolver.classForName(String) line: 51
ENumUserType.setParameterValues(Properties) line: 175

with Thread.getContextClassLoader() returning the following
contextClassLoader:
org.eclipse.core.runtime.internal.adaptor.ContextFinder@d82aff
with parent: sun.misc.Launcher$AppClassLoader@1a7bf11
with parent: sun.misc.Launcher$ExtClassLoader@1f12c4e
with parent: null

Then later in BookImpl eSet i get the following (where the CL matched
the one reported in the static constructor):
BookCaterogy CL:
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea
parent: org.eclipse.osgi.baseadaptor.BaseAdaptor$ParentClassLoader@16917ee
parent: null

The message in the BookCategory static constructor is only called once
at the beginning of this trace.

Also when you mentioned:
> In the debugger you can try to walk through the
> classloader hierarchy to see if the two classloaders are related.
Is there any way to walk the complete classloader hierarchy starting
from the root. What I am getting doesn't even agree on a root.

Thanks
Alain


Martin Taal wrote:
> Alain,
> I am not sure why this does not work but I can give you some more
> background information for you to look at. At your breakpoint in the
> BookImpl.eSet you can get the classloader from both the BookCategory
> class used for the cast as well as the classloader (getClassLoader()
> method on the class itself). The same can be done for the class of the
> passed object. In the debugger you can try to walk through the
> classloader hierarchy to see if the two classloaders are related.
>
> The (BookCategory) class of the passed object in the eSet is loaded in
> the EnumUserType class in the setParameterValues method. This is done
> when you initialize the datastore. As a default teneo uses the
> ContextClassLoaderStrategy (see org.eclipse.emf.teneo.classloader) which
> uses the following to load the class:
> Thread.currentThread().getContextClassLoader()
>
> I do not know how/when the second classloader (which reads its own
> BookCategory) comes into play. To analyse this it could help to put a
> static initializer block in the BookCategory class with a breakpoint (or
> print the stack trace) and then see when this is executed (twice).
>
> It seems that the initialization of the datastore uses a classloader
> which is not related to the classloader which later reads the library
> model again for your plugins.
>
> gr. Martin
>
> Alain Picard wrote:
>> Martin,
>>
>> I get a org.eclipse.example.library.BookCategory and it is being cast
>> to BookCategory as the error mentioned:
>> java.lang.ClassCastException: org.eclipse.example.library.BookCategory
>> cannot be cast to org.eclipse.example.library.BookCategory
>>
>> I am using the latest version of Teneo (0.8
>> emft-teneo-SDK-I200704230019) with EMF (emf-sdo-xsd-SDK-2.3.0M6) under
>> Eclipse 3.3M6
>>
>> I am trying to get some trace info to get the class loader tree, but I
>> am still fighting that battle.
>>
>> Thanks for your help.
>> Alain
>>
>>
>> Here is the mapping info:
>> <hibernate-mapping>
>> <class name="org.eclipse.example.library.impl.BookImpl"
>> entity-name="Book" abstract="false" lazy="false"
>> discriminator-value="Book" table="`book`">
>> <meta attribute="eclassName">Book</meta>
>> <meta
>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>> <id type="long" name="e_id" column="e_id"
>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>
>> <meta attribute="syntheticId">true</meta>
>> <generator class="native"/>
>> </id>
>> <discriminator column="`dtype`" type="string"/>
>> <version name="e_version" column="e_version"
>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>
>> <meta attribute="syntheticVersion">true</meta>
>> </version>
>> <property name="title" lazy="false" insert="true"
>> update="true" not-null="false" unique="false" type="java.lang.String">
>> <column not-null="false" unique="false" name="`title`"/>
>> </property>
>> <property name="pages" lazy="false" insert="true"
>> update="true" not-null="false" unique="false" type="int">
>> <column not-null="false" unique="false" name="`pages`"/>
>> </property>
>> <property name="category" lazy="false" not-null="false"
>> insert="true" update="true" unique="false">
>> <column not-null="false" unique="false" name="`category`"/>
>> <type
>> name="org.eclipse.emf.teneo.hibernate.mapping.ENumUserType" >
>> <param
>> name="enumClass">org.eclipse.example.library.BookCategory</param >
>> </type>
>> </property>
>> <many-to-one name="author" entity-name="Writer"
>> cascade="merge,persist,save-update,lock,refresh" lazy="false"
>> insert="false" update="false" not-null="false">
>> <column not-null="false" unique="false"
>> name="`book_author_e_id`"/>
>> </many-to-one>
>> </class>
>> <class name="org.eclipse.example.library.impl.LibraryImpl"
>> entity-name="Library" abstract="false" lazy="false"
>> discriminator-value="Library" table="`library`">
>> <meta attribute="eclassName">Library</meta>
>> <meta
>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>> <id type="long" name="e_id" column="e_id"
>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>
>> <meta attribute="syntheticId">true</meta>
>> <generator class="native"/>
>> </id>
>> <discriminator column="`dtype`" type="string"/>
>> <version name="e_version" column="e_version"
>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>
>> <meta attribute="syntheticVersion">true</meta>
>> </version>
>> <property name="name" lazy="false" insert="true" update="true"
>> not-null="false" unique="false" type="java.lang.String">
>> <column not-null="false" unique="false" name="`name`"/>
>> </property>
>> <list name="writers" lazy="true" cascade="all,delete-orphan">
>> <key update="true">
>> <column name="`library_writers_e_id`" not-null="false"
>> unique="false"/>
>> </key>
>> <list-index column="`library_writers_idx`"/>
>> <one-to-many entity-name="Writer"/>
>> </list>
>> <list name="books" lazy="true" cascade="all,delete-orphan">
>> <key update="true">
>> <column name="`library_books_e_id`" not-null="false"
>> unique="false"/>
>> </key>
>> <list-index column="`library_books_idx`"/>
>> <one-to-many entity-name="Book"/>
>> </list>
>> </class>
>> <class name="org.eclipse.example.library.impl.WriterImpl"
>> entity-name="Writer" abstract="false" lazy="false"
>> discriminator-value="Writer" table="`writer`">
>> <meta attribute="eclassName">Writer</meta>
>> <meta
>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>> <id type="long" name="e_id" column="e_id"
>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>
>> <meta attribute="syntheticId">true</meta>
>> <generator class="native"/>
>> </id>
>> <discriminator column="`dtype`" type="string"/>
>> <version name="e_version" column="e_version"
>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>
>> <meta attribute="syntheticVersion">true</meta>
>> </version>
>> <property name="name" lazy="false" insert="true" update="true"
>> not-null="false" unique="false" type="java.lang.String">
>> <column not-null="false" unique="false" name="`name`"/>
>> </property>
>> <list name="books" lazy="true"
>> cascade="merge,persist,save-update,lock,refresh">
>> <key update="true">
>> <column name="`book_author_e_id`" not-null="false"
>> unique="false"/>
>> </key>
>> <list-index column="`writer_books_idx`"/>
>> <one-to-many entity-name="Book"/>
>> </list>
>> </class>
>> </hibernate-mapping>
>>
>>
>> Martin Taal wrote:
>>> Alain,
>>> I am a bit mistified myself also, when you set a breakpoint here:
>>> BookImpl.eSet(BookImpl.java:309),
>>> what is the class of the object you get and what is the class
>>> instance to which the cast is tried?
>>>
>>> Which version of Teneo are you using?
>>> Can you post/send me the hbm mapping? (you can get it by doing
>>> dataStore.getMappingXML())
>>>
>>> gr. Martin
>>>
>>> Alain Picard wrote:
>>>> Martin,
>>>>
>>>> I just made the changes and did a clean build, started with -clean,
>>>> but to no avail.
>>>>
>>>> Any other idea?
>>>>
>>>> Alain
>>>>
>>>> Martin Taal wrote:
>>>>> Hi Alain,
>>>>> Can you try setting the buddy policy to dependent? Although it is
>>>>> less precise (classloading can take more time) it is the safest to
>>>>> try.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Alain Picard wrote:
>>>>>> I am getting acquainted with Teneo and going through the library
>>>>>> editor example (after successfully doing the Tutorial1 part). I
>>>>>> have been able to start the wizard on an empty database and to
>>>>>> create a library with a book and author.
>>>>>>
>>>>>> When I restart back from scratch, it attempts to load the content
>>>>>> of the db and fails with the following:
>>>>>> java.lang.ClassCastException:
>>>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>>>> org.eclipse.example.library.BookCategory
>>>>>> at
>>>>>> org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
>>>>>> at
>>>>>> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>>>>>>
>>>>>> .....etc
>>>>>>
>>>>>> This gives me the idea that I might be dealing with a classloader
>>>>>> problem, since my Hibernate jars are in a different bundle. I have
>>>>>> it's buddy policy set to registered and all of the library
>>>>>> projects have Eclipse-RegisterBuddy: Shared_JARs (the bundle
>>>>>> containing Hibernate).
>>>>>>
>>>>>> Does anyone has seen this before and have any clue how to fix it?
>>>>>>
>>>>>> Thanks
>>>>>> Alain
>>>>>
>>>>>
>>>
>>>
>
>
Re: [Teneo] ClassCastException retrieving model [message #81379 is a reply to message #81343] Fri, 27 April 2007 12:33 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Alain,
Hmm where do you initialise the datastore (in which plugin)?

Teneo can be set to use another classloader you can do this by calling the method:
ClassLoaderResolver.setClassLoaderStrategy(ClassLoaderStrate gy classLoaderStrategy)
with your own ClassLoaderStrategy before initializing the datastore.

The ClassLoaderStrategy is a simple interface which returns the classloader which you want to use.

As a default Teneo uses the ContextClassLoaderStrategy but there is also the
ClassClassLoaderStrategy which uses the classloader of the calling class.

gr. Martin

Alain Picard wrote:
> Martin,
>
> Here is what I am getting (in order):
> In static init of BookCategory.
> CL:org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea
>
> In ENumUserType with enumClassName of:
> org.eclipse.example.library.BookCategory
>
> then it goes to get the classForName:
> Thread.getContextClassLoader() line: 1314 [local variables unavailable]
> ContextClassLoaderStrategy.getClassLoader() line: 32
> ClassLoaderResolver.getClassLoader() line: 59
> ClassLoaderResolver.classForName(String) line: 51
> ENumUserType.setParameterValues(Properties) line: 175
>
> with Thread.getContextClassLoader() returning the following
> contextClassLoader:
> org.eclipse.core.runtime.internal.adaptor.ContextFinder@d82aff
> with parent: sun.misc.Launcher$AppClassLoader@1a7bf11
> with parent: sun.misc.Launcher$ExtClassLoader@1f12c4e
> with parent: null
>
> Then later in BookImpl eSet i get the following (where the CL matched
> the one reported in the static constructor):
> BookCaterogy CL:
> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea
> parent: org.eclipse.osgi.baseadaptor.BaseAdaptor$ParentClassLoader@16917ee
> parent: null
>
> The message in the BookCategory static constructor is only called once
> at the beginning of this trace.
>
> Also when you mentioned:
> > In the debugger you can try to walk through the
> > classloader hierarchy to see if the two classloaders are related.
> Is there any way to walk the complete classloader hierarchy starting
> from the root. What I am getting doesn't even agree on a root.
>
> Thanks
> Alain
>
>
> Martin Taal wrote:
>> Alain,
>> I am not sure why this does not work but I can give you some more
>> background information for you to look at. At your breakpoint in the
>> BookImpl.eSet you can get the classloader from both the BookCategory
>> class used for the cast as well as the classloader (getClassLoader()
>> method on the class itself). The same can be done for the class of the
>> passed object. In the debugger you can try to walk through the
>> classloader hierarchy to see if the two classloaders are related.
>>
>> The (BookCategory) class of the passed object in the eSet is loaded in
>> the EnumUserType class in the setParameterValues method. This is done
>> when you initialize the datastore. As a default teneo uses the
>> ContextClassLoaderStrategy (see org.eclipse.emf.teneo.classloader)
>> which uses the following to load the class:
>> Thread.currentThread().getContextClassLoader()
>>
>> I do not know how/when the second classloader (which reads its own
>> BookCategory) comes into play. To analyse this it could help to put a
>> static initializer block in the BookCategory class with a breakpoint
>> (or print the stack trace) and then see when this is executed (twice).
>>
>> It seems that the initialization of the datastore uses a classloader
>> which is not related to the classloader which later reads the library
>> model again for your plugins.
>>
>> gr. Martin
>>
>> Alain Picard wrote:
>>> Martin,
>>>
>>> I get a org.eclipse.example.library.BookCategory and it is being cast
>>> to BookCategory as the error mentioned:
>>> java.lang.ClassCastException:
>>> org.eclipse.example.library.BookCategory cannot be cast to
>>> org.eclipse.example.library.BookCategory
>>>
>>> I am using the latest version of Teneo (0.8
>>> emft-teneo-SDK-I200704230019) with EMF (emf-sdo-xsd-SDK-2.3.0M6)
>>> under Eclipse 3.3M6
>>>
>>> I am trying to get some trace info to get the class loader tree, but
>>> I am still fighting that battle.
>>>
>>> Thanks for your help.
>>> Alain
>>>
>>>
>>> Here is the mapping info:
>>> <hibernate-mapping>
>>> <class name="org.eclipse.example.library.impl.BookImpl"
>>> entity-name="Book" abstract="false" lazy="false"
>>> discriminator-value="Book" table="`book`">
>>> <meta attribute="eclassName">Book</meta>
>>> <meta
>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>> <id type="long" name="e_id" column="e_id"
>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>
>>> <meta attribute="syntheticId">true</meta>
>>> <generator class="native"/>
>>> </id>
>>> <discriminator column="`dtype`" type="string"/>
>>> <version name="e_version" column="e_version"
>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>
>>> <meta attribute="syntheticVersion">true</meta>
>>> </version>
>>> <property name="title" lazy="false" insert="true"
>>> update="true" not-null="false" unique="false" type="java.lang.String">
>>> <column not-null="false" unique="false" name="`title`"/>
>>> </property>
>>> <property name="pages" lazy="false" insert="true"
>>> update="true" not-null="false" unique="false" type="int">
>>> <column not-null="false" unique="false" name="`pages`"/>
>>> </property>
>>> <property name="category" lazy="false" not-null="false"
>>> insert="true" update="true" unique="false">
>>> <column not-null="false" unique="false" name="`category`"/>
>>> <type
>>> name="org.eclipse.emf.teneo.hibernate.mapping.ENumUserType" >
>>> <param
>>> name="enumClass">org.eclipse.example.library.BookCategory</param >
>>> </type>
>>> </property>
>>> <many-to-one name="author" entity-name="Writer"
>>> cascade="merge,persist,save-update,lock,refresh" lazy="false"
>>> insert="false" update="false" not-null="false">
>>> <column not-null="false" unique="false"
>>> name="`book_author_e_id`"/>
>>> </many-to-one>
>>> </class>
>>> <class name="org.eclipse.example.library.impl.LibraryImpl"
>>> entity-name="Library" abstract="false" lazy="false"
>>> discriminator-value="Library" table="`library`">
>>> <meta attribute="eclassName">Library</meta>
>>> <meta
>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>> <id type="long" name="e_id" column="e_id"
>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>
>>> <meta attribute="syntheticId">true</meta>
>>> <generator class="native"/>
>>> </id>
>>> <discriminator column="`dtype`" type="string"/>
>>> <version name="e_version" column="e_version"
>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>
>>> <meta attribute="syntheticVersion">true</meta>
>>> </version>
>>> <property name="name" lazy="false" insert="true"
>>> update="true" not-null="false" unique="false" type="java.lang.String">
>>> <column not-null="false" unique="false" name="`name`"/>
>>> </property>
>>> <list name="writers" lazy="true" cascade="all,delete-orphan">
>>> <key update="true">
>>> <column name="`library_writers_e_id`"
>>> not-null="false" unique="false"/>
>>> </key>
>>> <list-index column="`library_writers_idx`"/>
>>> <one-to-many entity-name="Writer"/>
>>> </list>
>>> <list name="books" lazy="true" cascade="all,delete-orphan">
>>> <key update="true">
>>> <column name="`library_books_e_id`" not-null="false"
>>> unique="false"/>
>>> </key>
>>> <list-index column="`library_books_idx`"/>
>>> <one-to-many entity-name="Book"/>
>>> </list>
>>> </class>
>>> <class name="org.eclipse.example.library.impl.WriterImpl"
>>> entity-name="Writer" abstract="false" lazy="false"
>>> discriminator-value="Writer" table="`writer`">
>>> <meta attribute="eclassName">Writer</meta>
>>> <meta
>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>> <id type="long" name="e_id" column="e_id"
>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>
>>> <meta attribute="syntheticId">true</meta>
>>> <generator class="native"/>
>>> </id>
>>> <discriminator column="`dtype`" type="string"/>
>>> <version name="e_version" column="e_version"
>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>
>>> <meta attribute="syntheticVersion">true</meta>
>>> </version>
>>> <property name="name" lazy="false" insert="true"
>>> update="true" not-null="false" unique="false" type="java.lang.String">
>>> <column not-null="false" unique="false" name="`name`"/>
>>> </property>
>>> <list name="books" lazy="true"
>>> cascade="merge,persist,save-update,lock,refresh">
>>> <key update="true">
>>> <column name="`book_author_e_id`" not-null="false"
>>> unique="false"/>
>>> </key>
>>> <list-index column="`writer_books_idx`"/>
>>> <one-to-many entity-name="Book"/>
>>> </list>
>>> </class>
>>> </hibernate-mapping>
>>>
>>>
>>> Martin Taal wrote:
>>>> Alain,
>>>> I am a bit mistified myself also, when you set a breakpoint here:
>>>> BookImpl.eSet(BookImpl.java:309),
>>>> what is the class of the object you get and what is the class
>>>> instance to which the cast is tried?
>>>>
>>>> Which version of Teneo are you using?
>>>> Can you post/send me the hbm mapping? (you can get it by doing
>>>> dataStore.getMappingXML())
>>>>
>>>> gr. Martin
>>>>
>>>> Alain Picard wrote:
>>>>> Martin,
>>>>>
>>>>> I just made the changes and did a clean build, started with -clean,
>>>>> but to no avail.
>>>>>
>>>>> Any other idea?
>>>>>
>>>>> Alain
>>>>>
>>>>> Martin Taal wrote:
>>>>>> Hi Alain,
>>>>>> Can you try setting the buddy policy to dependent? Although it is
>>>>>> less precise (classloading can take more time) it is the safest to
>>>>>> try.
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Alain Picard wrote:
>>>>>>> I am getting acquainted with Teneo and going through the library
>>>>>>> editor example (after successfully doing the Tutorial1 part). I
>>>>>>> have been able to start the wizard on an empty database and to
>>>>>>> create a library with a book and author.
>>>>>>>
>>>>>>> When I restart back from scratch, it attempts to load the content
>>>>>>> of the db and fails with the following:
>>>>>>> java.lang.ClassCastException:
>>>>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>>>>> org.eclipse.example.library.BookCategory
>>>>>>> at
>>>>>>> org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
>>>>>>> at
>>>>>>> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>>>>>>>
>>>>>>> at
>>>>>>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>>>>>>>
>>>>>>> at
>>>>>>> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>>>>>>>
>>>>>>> at
>>>>>>> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
>>>>>>>
>>>>>>> at
>>>>>>> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>>>>>>>
>>>>>>> .....etc
>>>>>>>
>>>>>>> This gives me the idea that I might be dealing with a classloader
>>>>>>> problem, since my Hibernate jars are in a different bundle. I
>>>>>>> have it's buddy policy set to registered and all of the library
>>>>>>> projects have Eclipse-RegisterBuddy: Shared_JARs (the bundle
>>>>>>> containing Hibernate).
>>>>>>>
>>>>>>> Does anyone has seen this before and have any clue how to fix it?
>>>>>>>
>>>>>>> Thanks
>>>>>>> Alain
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] ClassCastException retrieving model [message #81436 is a reply to message #81379] Sun, 29 April 2007 22:32 Go to previous messageGo to next message
Alain Picard is currently offline Alain PicardFriend
Messages: 235
Registered: July 2009
Senior Member
Martin,

Finally got it figured out.

I had to hack the java.lang.ClassLoader to implement a registry
( http://www.javaworld.com/javaworld/javaqa/2003-07/02-qa-0725 -classsrc2.html)
in order to understand what was happening. (Many other failed attempts
before)

Here is what I got:
[org.eclipse.example.library.BookCategory]:
loaded by
[org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader(org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@1201ad7)]
from
[file:/C:/eclipse/workspace/library/bin/org/eclipse/example/ library/BookCategory.class]

and then:
[org.eclipse.example.library.BookCategory]:
loaded by
[org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader(org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@1e7258e)]
from
[jar:file:/C:/eclipse/products/emft-teneo-ex-7423/eclipse/pl ugins/org.eclipse.emf.teneo.tutorial_0.8.0.v200704230019.jar !/org/eclipse/example/library/BookCategory.class]


Guess I had the example jar installed and getting in the way from my
original library project and that was also the reason i could only see 1
call to the static block in BookCategory.

Now I need to understand why I am getting a large number of empty "My
Library" under the single truly populated one.

Do you have any clue?

Thanks
Alain



Martin Taal wrote:
> Hi Alain,
> Hmm where do you initialise the datastore (in which plugin)?
>
> Teneo can be set to use another classloader you can do this by calling
> the method:
> ClassLoaderResolver.setClassLoaderStrategy(ClassLoaderStrate gy
> classLoaderStrategy)
> with your own ClassLoaderStrategy before initializing the datastore.
>
> The ClassLoaderStrategy is a simple interface which returns the
> classloader which you want to use.
>
> As a default Teneo uses the ContextClassLoaderStrategy but there is also
> the ClassClassLoaderStrategy which uses the classloader of the calling
> class.
>
> gr. Martin
>
> Alain Picard wrote:
>> Martin,
>>
>> Here is what I am getting (in order):
>> In static init of BookCategory.
>> CL:org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea
>>
>> In ENumUserType with enumClassName of:
>> org.eclipse.example.library.BookCategory
>>
>> then it goes to get the classForName:
>> Thread.getContextClassLoader() line: 1314 [local variables
>> unavailable] ContextClassLoaderStrategy.getClassLoader() line: 32
>> ClassLoaderResolver.getClassLoader() line: 59
>> ClassLoaderResolver.classForName(String) line: 51
>> ENumUserType.setParameterValues(Properties) line: 175
>> with Thread.getContextClassLoader() returning the following
>> contextClassLoader:
>> org.eclipse.core.runtime.internal.adaptor.ContextFinder@d82aff
>> with parent: sun.misc.Launcher$AppClassLoader@1a7bf11
>> with parent: sun.misc.Launcher$ExtClassLoader@1f12c4e
>> with parent: null
>>
>> Then later in BookImpl eSet i get the following (where the CL matched
>> the one reported in the static constructor):
>> BookCaterogy CL:
>> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea
>> parent:
>> org.eclipse.osgi.baseadaptor.BaseAdaptor$ParentClassLoader@16917ee
>> parent: null
>>
>> The message in the BookCategory static constructor is only called once
>> at the beginning of this trace.
>>
>> Also when you mentioned:
>> > In the debugger you can try to walk through the
>> > classloader hierarchy to see if the two classloaders are related.
>> Is there any way to walk the complete classloader hierarchy starting
>> from the root. What I am getting doesn't even agree on a root.
>>
>> Thanks
>> Alain
>>
>>
>> Martin Taal wrote:
>>> Alain,
>>> I am not sure why this does not work but I can give you some more
>>> background information for you to look at. At your breakpoint in the
>>> BookImpl.eSet you can get the classloader from both the BookCategory
>>> class used for the cast as well as the classloader (getClassLoader()
>>> method on the class itself). The same can be done for the class of
>>> the passed object. In the debugger you can try to walk through the
>>> classloader hierarchy to see if the two classloaders are related.
>>>
>>> The (BookCategory) class of the passed object in the eSet is loaded
>>> in the EnumUserType class in the setParameterValues method. This is
>>> done when you initialize the datastore. As a default teneo uses the
>>> ContextClassLoaderStrategy (see org.eclipse.emf.teneo.classloader)
>>> which uses the following to load the class:
>>> Thread.currentThread().getContextClassLoader()
>>>
>>> I do not know how/when the second classloader (which reads its own
>>> BookCategory) comes into play. To analyse this it could help to put a
>>> static initializer block in the BookCategory class with a breakpoint
>>> (or print the stack trace) and then see when this is executed (twice).
>>>
>>> It seems that the initialization of the datastore uses a classloader
>>> which is not related to the classloader which later reads the library
>>> model again for your plugins.
>>>
>>> gr. Martin
>>>
>>> Alain Picard wrote:
>>>> Martin,
>>>>
>>>> I get a org.eclipse.example.library.BookCategory and it is being
>>>> cast to BookCategory as the error mentioned:
>>>> java.lang.ClassCastException:
>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>> org.eclipse.example.library.BookCategory
>>>>
>>>> I am using the latest version of Teneo (0.8
>>>> emft-teneo-SDK-I200704230019) with EMF (emf-sdo-xsd-SDK-2.3.0M6)
>>>> under Eclipse 3.3M6
>>>>
>>>> I am trying to get some trace info to get the class loader tree, but
>>>> I am still fighting that battle.
>>>>
>>>> Thanks for your help.
>>>> Alain
>>>>
>>>>
>>>> Here is the mapping info:
>>>> <hibernate-mapping>
>>>> <class name="org.eclipse.example.library.impl.BookImpl"
>>>> entity-name="Book" abstract="false" lazy="false"
>>>> discriminator-value="Book" table="`book`">
>>>> <meta attribute="eclassName">Book</meta>
>>>> <meta
>>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>>> <id type="long" name="e_id" column="e_id"
>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>
>>>> <meta attribute="syntheticId">true</meta>
>>>> <generator class="native"/>
>>>> </id>
>>>> <discriminator column="`dtype`" type="string"/>
>>>> <version name="e_version" column="e_version"
>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>>
>>>> <meta attribute="syntheticVersion">true</meta>
>>>> </version>
>>>> <property name="title" lazy="false" insert="true"
>>>> update="true" not-null="false" unique="false" type="java.lang.String">
>>>> <column not-null="false" unique="false" name="`title`"/>
>>>> </property>
>>>> <property name="pages" lazy="false" insert="true"
>>>> update="true" not-null="false" unique="false" type="int">
>>>> <column not-null="false" unique="false" name="`pages`"/>
>>>> </property>
>>>> <property name="category" lazy="false" not-null="false"
>>>> insert="true" update="true" unique="false">
>>>> <column not-null="false" unique="false" name="`category`"/>
>>>> <type
>>>> name="org.eclipse.emf.teneo.hibernate.mapping.ENumUserType" >
>>>> <param
>>>> name="enumClass">org.eclipse.example.library.BookCategory</param >
>>>> </type>
>>>> </property>
>>>> <many-to-one name="author" entity-name="Writer"
>>>> cascade="merge,persist,save-update,lock,refresh" lazy="false"
>>>> insert="false" update="false" not-null="false">
>>>> <column not-null="false" unique="false"
>>>> name="`book_author_e_id`"/>
>>>> </many-to-one>
>>>> </class>
>>>> <class name="org.eclipse.example.library.impl.LibraryImpl"
>>>> entity-name="Library" abstract="false" lazy="false"
>>>> discriminator-value="Library" table="`library`">
>>>> <meta attribute="eclassName">Library</meta>
>>>> <meta
>>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>>> <id type="long" name="e_id" column="e_id"
>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>
>>>> <meta attribute="syntheticId">true</meta>
>>>> <generator class="native"/>
>>>> </id>
>>>> <discriminator column="`dtype`" type="string"/>
>>>> <version name="e_version" column="e_version"
>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>>
>>>> <meta attribute="syntheticVersion">true</meta>
>>>> </version>
>>>> <property name="name" lazy="false" insert="true"
>>>> update="true" not-null="false" unique="false" type="java.lang.String">
>>>> <column not-null="false" unique="false" name="`name`"/>
>>>> </property>
>>>> <list name="writers" lazy="true" cascade="all,delete-orphan">
>>>> <key update="true">
>>>> <column name="`library_writers_e_id`"
>>>> not-null="false" unique="false"/>
>>>> </key>
>>>> <list-index column="`library_writers_idx`"/>
>>>> <one-to-many entity-name="Writer"/>
>>>> </list>
>>>> <list name="books" lazy="true" cascade="all,delete-orphan">
>>>> <key update="true">
>>>> <column name="`library_books_e_id`" not-null="false"
>>>> unique="false"/>
>>>> </key>
>>>> <list-index column="`library_books_idx`"/>
>>>> <one-to-many entity-name="Book"/>
>>>> </list>
>>>> </class>
>>>> <class name="org.eclipse.example.library.impl.WriterImpl"
>>>> entity-name="Writer" abstract="false" lazy="false"
>>>> discriminator-value="Writer" table="`writer`">
>>>> <meta attribute="eclassName">Writer</meta>
>>>> <meta
>>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>>> <id type="long" name="e_id" column="e_id"
>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>
>>>> <meta attribute="syntheticId">true</meta>
>>>> <generator class="native"/>
>>>> </id>
>>>> <discriminator column="`dtype`" type="string"/>
>>>> <version name="e_version" column="e_version"
>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>>
>>>> <meta attribute="syntheticVersion">true</meta>
>>>> </version>
>>>> <property name="name" lazy="false" insert="true"
>>>> update="true" not-null="false" unique="false" type="java.lang.String">
>>>> <column not-null="false" unique="false" name="`name`"/>
>>>> </property>
>>>> <list name="books" lazy="true"
>>>> cascade="merge,persist,save-update,lock,refresh">
>>>> <key update="true">
>>>> <column name="`book_author_e_id`" not-null="false"
>>>> unique="false"/>
>>>> </key>
>>>> <list-index column="`writer_books_idx`"/>
>>>> <one-to-many entity-name="Book"/>
>>>> </list>
>>>> </class>
>>>> </hibernate-mapping>
>>>>
>>>>
>>>> Martin Taal wrote:
>>>>> Alain,
>>>>> I am a bit mistified myself also, when you set a breakpoint here:
>>>>> BookImpl.eSet(BookImpl.java:309),
>>>>> what is the class of the object you get and what is the class
>>>>> instance to which the cast is tried?
>>>>>
>>>>> Which version of Teneo are you using?
>>>>> Can you post/send me the hbm mapping? (you can get it by doing
>>>>> dataStore.getMappingXML())
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Alain Picard wrote:
>>>>>> Martin,
>>>>>>
>>>>>> I just made the changes and did a clean build, started with
>>>>>> -clean, but to no avail.
>>>>>>
>>>>>> Any other idea?
>>>>>>
>>>>>> Alain
>>>>>>
>>>>>> Martin Taal wrote:
>>>>>>> Hi Alain,
>>>>>>> Can you try setting the buddy policy to dependent? Although it is
>>>>>>> less precise (classloading can take more time) it is the safest
>>>>>>> to try.
>>>>>>>
>>>>>>> gr. Martin
>>>>>>>
>>>>>>> Alain Picard wrote:
>>>>>>>> I am getting acquainted with Teneo and going through the library
>>>>>>>> editor example (after successfully doing the Tutorial1 part). I
>>>>>>>> have been able to start the wizard on an empty database and to
>>>>>>>> create a library with a book and author.
>>>>>>>>
>>>>>>>> When I restart back from scratch, it attempts to load the
>>>>>>>> content of the db and fails with the following:
>>>>>>>> java.lang.ClassCastException:
>>>>>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>>>>>> org.eclipse.example.library.BookCategory
>>>>>>>> at
>>>>>>>> org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
>>>>>>>> at
>>>>>>>> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>>>>>>>>
>>>>>>>> at
>>>>>>>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>>>>>>>>
>>>>>>>> at
>>>>>>>> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>>>>>>>>
>>>>>>>> at
>>>>>>>> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
>>>>>>>>
>>>>>>>> at
>>>>>>>> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>>>>>>>>
>>>>>>>> .....etc
>>>>>>>>
>>>>>>>> This gives me the idea that I might be dealing with a
>>>>>>>> classloader problem, since my Hibernate jars are in a different
>>>>>>>> bundle. I have it's buddy policy set to registered and all of
>>>>>>>> the library projects have Eclipse-RegisterBuddy: Shared_JARs
>>>>>>>> (the bundle containing Hibernate).
>>>>>>>>
>>>>>>>> Does anyone has seen this before and have any clue how to fix it?
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>> Alain
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Re: [Teneo] ClassCastException retrieving model [message #81450 is a reply to message #81436] Mon, 30 April 2007 07:39 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Alain,
Thanks for the link, interesting article. It is a pity that java does not make this easier in the
standard sdk.

I am not sure what you do so I can not really answer the question why you get many empty libraries.
Maybe it is related to code which automatically creates a root object (a library) to prevent the
database from being empty (just guessing here).

gr. Martin

Alain Picard wrote:
> Martin,
>
> Finally got it figured out.
>
> I had to hack the java.lang.ClassLoader to implement a registry
> ( http://www.javaworld.com/javaworld/javaqa/2003-07/02-qa-0725 -classsrc2.html)
> in order to understand what was happening. (Many other failed attempts
> before)
>
> Here is what I got:
> [org.eclipse.example.library.BookCategory]:
> loaded by
> [org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader(org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@1201ad7)]
>
> from
> [file:/C:/eclipse/workspace/library/bin/org/eclipse/example/ library/BookCategory.class]
>
>
> and then:
> [org.eclipse.example.library.BookCategory]:
> loaded by
> [org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader(org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@1e7258e)]
>
> from
> [jar:file:/C:/eclipse/products/emft-teneo-ex-7423/eclipse/pl ugins/org.eclipse.emf.teneo.tutorial_0.8.0.v200704230019.jar !/org/eclipse/example/library/BookCategory.class]
>
>
>
> Guess I had the example jar installed and getting in the way from my
> original library project and that was also the reason i could only see 1
> call to the static block in BookCategory.
>
> Now I need to understand why I am getting a large number of empty "My
> Library" under the single truly populated one.
>
> Do you have any clue?
>
> Thanks
> Alain
>
>
>
> Martin Taal wrote:
>> Hi Alain,
>> Hmm where do you initialise the datastore (in which plugin)?
>>
>> Teneo can be set to use another classloader you can do this by calling
>> the method:
>> ClassLoaderResolver.setClassLoaderStrategy(ClassLoaderStrate gy
>> classLoaderStrategy)
>> with your own ClassLoaderStrategy before initializing the datastore.
>>
>> The ClassLoaderStrategy is a simple interface which returns the
>> classloader which you want to use.
>>
>> As a default Teneo uses the ContextClassLoaderStrategy but there is
>> also the ClassClassLoaderStrategy which uses the classloader of the
>> calling class.
>>
>> gr. Martin
>>
>> Alain Picard wrote:
>>> Martin,
>>>
>>> Here is what I am getting (in order):
>>> In static init of BookCategory.
>>> CL:org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea
>>>
>>> In ENumUserType with enumClassName of:
>>> org.eclipse.example.library.BookCategory
>>>
>>> then it goes to get the classForName:
>>> Thread.getContextClassLoader() line: 1314 [local variables
>>> unavailable] ContextClassLoaderStrategy.getClassLoader() line: 32
>>> ClassLoaderResolver.getClassLoader() line: 59
>>> ClassLoaderResolver.classForName(String) line: 51
>>> ENumUserType.setParameterValues(Properties) line: 175 with
>>> Thread.getContextClassLoader() returning the following
>>> contextClassLoader:
>>> org.eclipse.core.runtime.internal.adaptor.ContextFinder@d82aff
>>> with parent: sun.misc.Launcher$AppClassLoader@1a7bf11
>>> with parent: sun.misc.Launcher$ExtClassLoader@1f12c4e
>>> with parent: null
>>>
>>> Then later in BookImpl eSet i get the following (where the CL matched
>>> the one reported in the static constructor):
>>> BookCaterogy CL:
>>> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea
>>> parent:
>>> org.eclipse.osgi.baseadaptor.BaseAdaptor$ParentClassLoader@16917ee
>>> parent: null
>>>
>>> The message in the BookCategory static constructor is only called
>>> once at the beginning of this trace.
>>>
>>> Also when you mentioned:
>>> > In the debugger you can try to walk through the
>>> > classloader hierarchy to see if the two classloaders are related.
>>> Is there any way to walk the complete classloader hierarchy starting
>>> from the root. What I am getting doesn't even agree on a root.
>>>
>>> Thanks
>>> Alain
>>>
>>>
>>> Martin Taal wrote:
>>>> Alain,
>>>> I am not sure why this does not work but I can give you some more
>>>> background information for you to look at. At your breakpoint in the
>>>> BookImpl.eSet you can get the classloader from both the BookCategory
>>>> class used for the cast as well as the classloader (getClassLoader()
>>>> method on the class itself). The same can be done for the class of
>>>> the passed object. In the debugger you can try to walk through the
>>>> classloader hierarchy to see if the two classloaders are related.
>>>>
>>>> The (BookCategory) class of the passed object in the eSet is loaded
>>>> in the EnumUserType class in the setParameterValues method. This is
>>>> done when you initialize the datastore. As a default teneo uses the
>>>> ContextClassLoaderStrategy (see org.eclipse.emf.teneo.classloader)
>>>> which uses the following to load the class:
>>>> Thread.currentThread().getContextClassLoader()
>>>>
>>>> I do not know how/when the second classloader (which reads its own
>>>> BookCategory) comes into play. To analyse this it could help to put
>>>> a static initializer block in the BookCategory class with a
>>>> breakpoint (or print the stack trace) and then see when this is
>>>> executed (twice).
>>>>
>>>> It seems that the initialization of the datastore uses a classloader
>>>> which is not related to the classloader which later reads the
>>>> library model again for your plugins.
>>>>
>>>> gr. Martin
>>>>
>>>> Alain Picard wrote:
>>>>> Martin,
>>>>>
>>>>> I get a org.eclipse.example.library.BookCategory and it is being
>>>>> cast to BookCategory as the error mentioned:
>>>>> java.lang.ClassCastException:
>>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>>> org.eclipse.example.library.BookCategory
>>>>>
>>>>> I am using the latest version of Teneo (0.8
>>>>> emft-teneo-SDK-I200704230019) with EMF (emf-sdo-xsd-SDK-2.3.0M6)
>>>>> under Eclipse 3.3M6
>>>>>
>>>>> I am trying to get some trace info to get the class loader tree,
>>>>> but I am still fighting that battle.
>>>>>
>>>>> Thanks for your help.
>>>>> Alain
>>>>>
>>>>>
>>>>> Here is the mapping info:
>>>>> <hibernate-mapping>
>>>>> <class name="org.eclipse.example.library.impl.BookImpl"
>>>>> entity-name="Book" abstract="false" lazy="false"
>>>>> discriminator-value="Book" table="`book`">
>>>>> <meta attribute="eclassName">Book</meta>
>>>>> <meta
>>>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>>>> <id type="long" name="e_id" column="e_id"
>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>>
>>>>> <meta attribute="syntheticId">true</meta>
>>>>> <generator class="native"/>
>>>>> </id>
>>>>> <discriminator column="`dtype`" type="string"/>
>>>>> <version name="e_version" column="e_version"
>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>>>
>>>>> <meta attribute="syntheticVersion">true</meta>
>>>>> </version>
>>>>> <property name="title" lazy="false" insert="true"
>>>>> update="true" not-null="false" unique="false" type="java.lang.String">
>>>>> <column not-null="false" unique="false" name="`title`"/>
>>>>> </property>
>>>>> <property name="pages" lazy="false" insert="true"
>>>>> update="true" not-null="false" unique="false" type="int">
>>>>> <column not-null="false" unique="false" name="`pages`"/>
>>>>> </property>
>>>>> <property name="category" lazy="false" not-null="false"
>>>>> insert="true" update="true" unique="false">
>>>>> <column not-null="false" unique="false"
>>>>> name="`category`"/>
>>>>> <type
>>>>> name="org.eclipse.emf.teneo.hibernate.mapping.ENumUserType" >
>>>>> <param
>>>>> name="enumClass">org.eclipse.example.library.BookCategory</param >
>>>>> </type>
>>>>> </property>
>>>>> <many-to-one name="author" entity-name="Writer"
>>>>> cascade="merge,persist,save-update,lock,refresh" lazy="false"
>>>>> insert="false" update="false" not-null="false">
>>>>> <column not-null="false" unique="false"
>>>>> name="`book_author_e_id`"/>
>>>>> </many-to-one>
>>>>> </class>
>>>>> <class name="org.eclipse.example.library.impl.LibraryImpl"
>>>>> entity-name="Library" abstract="false" lazy="false"
>>>>> discriminator-value="Library" table="`library`">
>>>>> <meta attribute="eclassName">Library</meta>
>>>>> <meta
>>>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>>>> <id type="long" name="e_id" column="e_id"
>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>>
>>>>> <meta attribute="syntheticId">true</meta>
>>>>> <generator class="native"/>
>>>>> </id>
>>>>> <discriminator column="`dtype`" type="string"/>
>>>>> <version name="e_version" column="e_version"
>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>>>
>>>>> <meta attribute="syntheticVersion">true</meta>
>>>>> </version>
>>>>> <property name="name" lazy="false" insert="true"
>>>>> update="true" not-null="false" unique="false" type="java.lang.String">
>>>>> <column not-null="false" unique="false" name="`name`"/>
>>>>> </property>
>>>>> <list name="writers" lazy="true" cascade="all,delete-orphan">
>>>>> <key update="true">
>>>>> <column name="`library_writers_e_id`"
>>>>> not-null="false" unique="false"/>
>>>>> </key>
>>>>> <list-index column="`library_writers_idx`"/>
>>>>> <one-to-many entity-name="Writer"/>
>>>>> </list>
>>>>> <list name="books" lazy="true" cascade="all,delete-orphan">
>>>>> <key update="true">
>>>>> <column name="`library_books_e_id`"
>>>>> not-null="false" unique="false"/>
>>>>> </key>
>>>>> <list-index column="`library_books_idx`"/>
>>>>> <one-to-many entity-name="Book"/>
>>>>> </list>
>>>>> </class>
>>>>> <class name="org.eclipse.example.library.impl.WriterImpl"
>>>>> entity-name="Writer" abstract="false" lazy="false"
>>>>> discriminator-value="Writer" table="`writer`">
>>>>> <meta attribute="eclassName">Writer</meta>
>>>>> <meta
>>>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>>>> <id type="long" name="e_id" column="e_id"
>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>>
>>>>> <meta attribute="syntheticId">true</meta>
>>>>> <generator class="native"/>
>>>>> </id>
>>>>> <discriminator column="`dtype`" type="string"/>
>>>>> <version name="e_version" column="e_version"
>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>>>
>>>>> <meta attribute="syntheticVersion">true</meta>
>>>>> </version>
>>>>> <property name="name" lazy="false" insert="true"
>>>>> update="true" not-null="false" unique="false" type="java.lang.String">
>>>>> <column not-null="false" unique="false" name="`name`"/>
>>>>> </property>
>>>>> <list name="books" lazy="true"
>>>>> cascade="merge,persist,save-update,lock,refresh">
>>>>> <key update="true">
>>>>> <column name="`book_author_e_id`" not-null="false"
>>>>> unique="false"/>
>>>>> </key>
>>>>> <list-index column="`writer_books_idx`"/>
>>>>> <one-to-many entity-name="Book"/>
>>>>> </list>
>>>>> </class>
>>>>> </hibernate-mapping>
>>>>>
>>>>>
>>>>> Martin Taal wrote:
>>>>>> Alain,
>>>>>> I am a bit mistified myself also, when you set a breakpoint here:
>>>>>> BookImpl.eSet(BookImpl.java:309),
>>>>>> what is the class of the object you get and what is the class
>>>>>> instance to which the cast is tried?
>>>>>>
>>>>>> Which version of Teneo are you using?
>>>>>> Can you post/send me the hbm mapping? (you can get it by doing
>>>>>> dataStore.getMappingXML())
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Alain Picard wrote:
>>>>>>> Martin,
>>>>>>>
>>>>>>> I just made the changes and did a clean build, started with
>>>>>>> -clean, but to no avail.
>>>>>>>
>>>>>>> Any other idea?
>>>>>>>
>>>>>>> Alain
>>>>>>>
>>>>>>> Martin Taal wrote:
>>>>>>>> Hi Alain,
>>>>>>>> Can you try setting the buddy policy to dependent? Although it
>>>>>>>> is less precise (classloading can take more time) it is the
>>>>>>>> safest to try.
>>>>>>>>
>>>>>>>> gr. Martin
>>>>>>>>
>>>>>>>> Alain Picard wrote:
>>>>>>>>> I am getting acquainted with Teneo and going through the
>>>>>>>>> library editor example (after successfully doing the Tutorial1
>>>>>>>>> part). I have been able to start the wizard on an empty
>>>>>>>>> database and to create a library with a book and author.
>>>>>>>>>
>>>>>>>>> When I restart back from scratch, it attempts to load the
>>>>>>>>> content of the db and fails with the following:
>>>>>>>>> java.lang.ClassCastException:
>>>>>>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>>>>>>> org.eclipse.example.library.BookCategory
>>>>>>>>> at
>>>>>>>>> org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
>>>>>>>>> at
>>>>>>>>> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>>>>>>>>>
>>>>>>>>> at
>>>>>>>>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>>>>>>>>>
>>>>>>>>> at
>>>>>>>>> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>>>>>>>>>
>>>>>>>>> at
>>>>>>>>> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
>>>>>>>>>
>>>>>>>>> at
>>>>>>>>> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>>>>>>>>>
>>>>>>>>> .....etc
>>>>>>>>>
>>>>>>>>> This gives me the idea that I might be dealing with a
>>>>>>>>> classloader problem, since my Hibernate jars are in a different
>>>>>>>>> bundle. I have it's buddy policy set to registered and all of
>>>>>>>>> the library projects have Eclipse-RegisterBuddy: Shared_JARs
>>>>>>>>> (the bundle containing Hibernate).
>>>>>>>>>
>>>>>>>>> Does anyone has seen this before and have any clue how to fix it?
>>>>>>>>>
>>>>>>>>> Thanks
>>>>>>>>> Alain
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] ClassCastException retrieving model [message #81601 is a reply to message #81450] Mon, 30 April 2007 13:30 Go to previous message
Alain Picard is currently offline Alain PicardFriend
Messages: 235
Registered: July 2009
Senior Member
Martin,

I guess it was due to the error situation and I kept creating empty root
objects as I kept testing somehow. I cleaned them from the database and
all is well now.

I am now getting closer to doing some real world tests very soon. :)

Thanks,
Alain


Martin Taal wrote:
> Hi Alain,
> Thanks for the link, interesting article. It is a pity that java does
> not make this easier in the standard sdk.
>
> I am not sure what you do so I can not really answer the question why
> you get many empty libraries. Maybe it is related to code which
> automatically creates a root object (a library) to prevent the database
> from being empty (just guessing here).
>
> gr. Martin
>
> Alain Picard wrote:
>> Martin,
>>
>> Finally got it figured out.
>>
>> I had to hack the java.lang.ClassLoader to implement a registry
>> ( http://www.javaworld.com/javaworld/javaqa/2003-07/02-qa-0725 -classsrc2.html)
>> in order to understand what was happening. (Many other failed attempts
>> before)
>>
>> Here is what I got:
>> [org.eclipse.example.library.BookCategory]:
>> loaded by
>> [org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader(org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@1201ad7)]
>>
>> from
>> [file:/C:/eclipse/workspace/library/bin/org/eclipse/example/ library/BookCategory.class]
>>
>>
>> and then:
>> [org.eclipse.example.library.BookCategory]:
>> loaded by
>> [org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader(org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@1e7258e)]
>>
>> from
>> [jar:file:/C:/eclipse/products/emft-teneo-ex-7423/eclipse/pl ugins/org.eclipse.emf.teneo.tutorial_0.8.0.v200704230019.jar !/org/eclipse/example/library/BookCategory.class]
>>
>>
>>
>> Guess I had the example jar installed and getting in the way from my
>> original library project and that was also the reason i could only see
>> 1 call to the static block in BookCategory.
>>
>> Now I need to understand why I am getting a large number of empty "My
>> Library" under the single truly populated one.
>>
>> Do you have any clue?
>>
>> Thanks
>> Alain
>>
>>
>>
>> Martin Taal wrote:
>>> Hi Alain,
>>> Hmm where do you initialise the datastore (in which plugin)?
>>>
>>> Teneo can be set to use another classloader you can do this by
>>> calling the method:
>>> ClassLoaderResolver.setClassLoaderStrategy(ClassLoaderStrate gy
>>> classLoaderStrategy)
>>> with your own ClassLoaderStrategy before initializing the datastore.
>>>
>>> The ClassLoaderStrategy is a simple interface which returns the
>>> classloader which you want to use.
>>>
>>> As a default Teneo uses the ContextClassLoaderStrategy but there is
>>> also the ClassClassLoaderStrategy which uses the classloader of the
>>> calling class.
>>>
>>> gr. Martin
>>>
>>> Alain Picard wrote:
>>>> Martin,
>>>>
>>>> Here is what I am getting (in order):
>>>> In static init of BookCategory.
>>>> CL:org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea
>>>>
>>>> In ENumUserType with enumClassName of:
>>>> org.eclipse.example.library.BookCategory
>>>>
>>>> then it goes to get the classForName:
>>>> Thread.getContextClassLoader() line: 1314 [local variables
>>>> unavailable] ContextClassLoaderStrategy.getClassLoader() line:
>>>> 32 ClassLoaderResolver.getClassLoader() line: 59
>>>> ClassLoaderResolver.classForName(String) line: 51
>>>> ENumUserType.setParameterValues(Properties) line: 175 with
>>>> Thread.getContextClassLoader() returning the following
>>>> contextClassLoader:
>>>> org.eclipse.core.runtime.internal.adaptor.ContextFinder@d82aff
>>>> with parent: sun.misc.Launcher$AppClassLoader@1a7bf11
>>>> with parent: sun.misc.Launcher$ExtClassLoader@1f12c4e
>>>> with parent: null
>>>>
>>>> Then later in BookImpl eSet i get the following (where the CL
>>>> matched the one reported in the static constructor):
>>>> BookCaterogy CL:
>>>> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea
>>>> parent:
>>>> org.eclipse.osgi.baseadaptor.BaseAdaptor$ParentClassLoader@16917ee
>>>> parent: null
>>>>
>>>> The message in the BookCategory static constructor is only called
>>>> once at the beginning of this trace.
>>>>
>>>> Also when you mentioned:
>>>> > In the debugger you can try to walk through the
>>>> > classloader hierarchy to see if the two classloaders are related.
>>>> Is there any way to walk the complete classloader hierarchy starting
>>>> from the root. What I am getting doesn't even agree on a root.
>>>>
>>>> Thanks
>>>> Alain
>>>>
>>>>
>>>> Martin Taal wrote:
>>>>> Alain,
>>>>> I am not sure why this does not work but I can give you some more
>>>>> background information for you to look at. At your breakpoint in
>>>>> the BookImpl.eSet you can get the classloader from both the
>>>>> BookCategory class used for the cast as well as the classloader
>>>>> (getClassLoader() method on the class itself). The same can be done
>>>>> for the class of the passed object. In the debugger you can try to
>>>>> walk through the classloader hierarchy to see if the two
>>>>> classloaders are related.
>>>>>
>>>>> The (BookCategory) class of the passed object in the eSet is loaded
>>>>> in the EnumUserType class in the setParameterValues method. This is
>>>>> done when you initialize the datastore. As a default teneo uses the
>>>>> ContextClassLoaderStrategy (see org.eclipse.emf.teneo.classloader)
>>>>> which uses the following to load the class:
>>>>> Thread.currentThread().getContextClassLoader()
>>>>>
>>>>> I do not know how/when the second classloader (which reads its own
>>>>> BookCategory) comes into play. To analyse this it could help to put
>>>>> a static initializer block in the BookCategory class with a
>>>>> breakpoint (or print the stack trace) and then see when this is
>>>>> executed (twice).
>>>>>
>>>>> It seems that the initialization of the datastore uses a
>>>>> classloader which is not related to the classloader which later
>>>>> reads the library model again for your plugins.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Alain Picard wrote:
>>>>>> Martin,
>>>>>>
>>>>>> I get a org.eclipse.example.library.BookCategory and it is being
>>>>>> cast to BookCategory as the error mentioned:
>>>>>> java.lang.ClassCastException:
>>>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>>>> org.eclipse.example.library.BookCategory
>>>>>>
>>>>>> I am using the latest version of Teneo (0.8
>>>>>> emft-teneo-SDK-I200704230019) with EMF (emf-sdo-xsd-SDK-2.3.0M6)
>>>>>> under Eclipse 3.3M6
>>>>>>
>>>>>> I am trying to get some trace info to get the class loader tree,
>>>>>> but I am still fighting that battle.
>>>>>>
>>>>>> Thanks for your help.
>>>>>> Alain
>>>>>>
>>>>>>
>>>>>> Here is the mapping info:
>>>>>> <hibernate-mapping>
>>>>>> <class name="org.eclipse.example.library.impl.BookImpl"
>>>>>> entity-name="Book" abstract="false" lazy="false"
>>>>>> discriminator-value="Book" table="`book`">
>>>>>> <meta attribute="eclassName">Book</meta>
>>>>>> <meta
>>>>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>>>>> <id type="long" name="e_id" column="e_id"
>>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>>>
>>>>>> <meta attribute="syntheticId">true</meta>
>>>>>> <generator class="native"/>
>>>>>> </id>
>>>>>> <discriminator column="`dtype`" type="string"/>
>>>>>> <version name="e_version" column="e_version"
>>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>>>>
>>>>>> <meta attribute="syntheticVersion">true</meta>
>>>>>> </version>
>>>>>> <property name="title" lazy="false" insert="true"
>>>>>> update="true" not-null="false" unique="false"
>>>>>> type="java.lang.String">
>>>>>> <column not-null="false" unique="false" name="`title`"/>
>>>>>> </property>
>>>>>> <property name="pages" lazy="false" insert="true"
>>>>>> update="true" not-null="false" unique="false" type="int">
>>>>>> <column not-null="false" unique="false" name="`pages`"/>
>>>>>> </property>
>>>>>> <property name="category" lazy="false" not-null="false"
>>>>>> insert="true" update="true" unique="false">
>>>>>> <column not-null="false" unique="false"
>>>>>> name="`category`"/>
>>>>>> <type
>>>>>> name="org.eclipse.emf.teneo.hibernate.mapping.ENumUserType" >
>>>>>> <param
>>>>>> name="enumClass">org.eclipse.example.library.BookCategory</param >
>>>>>> </type>
>>>>>> </property>
>>>>>> <many-to-one name="author" entity-name="Writer"
>>>>>> cascade="merge,persist,save-update,lock,refresh" lazy="false"
>>>>>> insert="false" update="false" not-null="false">
>>>>>> <column not-null="false" unique="false"
>>>>>> name="`book_author_e_id`"/>
>>>>>> </many-to-one>
>>>>>> </class>
>>>>>> <class name="org.eclipse.example.library.impl.LibraryImpl"
>>>>>> entity-name="Library" abstract="false" lazy="false"
>>>>>> discriminator-value="Library" table="`library`">
>>>>>> <meta attribute="eclassName">Library</meta>
>>>>>> <meta
>>>>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>>>>> <id type="long" name="e_id" column="e_id"
>>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>>>
>>>>>> <meta attribute="syntheticId">true</meta>
>>>>>> <generator class="native"/>
>>>>>> </id>
>>>>>> <discriminator column="`dtype`" type="string"/>
>>>>>> <version name="e_version" column="e_version"
>>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>>>>
>>>>>> <meta attribute="syntheticVersion">true</meta>
>>>>>> </version>
>>>>>> <property name="name" lazy="false" insert="true"
>>>>>> update="true" not-null="false" unique="false"
>>>>>> type="java.lang.String">
>>>>>> <column not-null="false" unique="false" name="`name`"/>
>>>>>> </property>
>>>>>> <list name="writers" lazy="true" cascade="all,delete-orphan">
>>>>>> <key update="true">
>>>>>> <column name="`library_writers_e_id`"
>>>>>> not-null="false" unique="false"/>
>>>>>> </key>
>>>>>> <list-index column="`library_writers_idx`"/>
>>>>>> <one-to-many entity-name="Writer"/>
>>>>>> </list>
>>>>>> <list name="books" lazy="true" cascade="all,delete-orphan">
>>>>>> <key update="true">
>>>>>> <column name="`library_books_e_id`"
>>>>>> not-null="false" unique="false"/>
>>>>>> </key>
>>>>>> <list-index column="`library_books_idx`"/>
>>>>>> <one-to-many entity-name="Book"/>
>>>>>> </list>
>>>>>> </class>
>>>>>> <class name="org.eclipse.example.library.impl.WriterImpl"
>>>>>> entity-name="Writer" abstract="false" lazy="false"
>>>>>> discriminator-value="Writer" table="`writer`">
>>>>>> <meta attribute="eclassName">Writer</meta>
>>>>>> <meta
>>>>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>>>>> <id type="long" name="e_id" column="e_id"
>>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>>>
>>>>>> <meta attribute="syntheticId">true</meta>
>>>>>> <generator class="native"/>
>>>>>> </id>
>>>>>> <discriminator column="`dtype`" type="string"/>
>>>>>> <version name="e_version" column="e_version"
>>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>>>>
>>>>>> <meta attribute="syntheticVersion">true</meta>
>>>>>> </version>
>>>>>> <property name="name" lazy="false" insert="true"
>>>>>> update="true" not-null="false" unique="false"
>>>>>> type="java.lang.String">
>>>>>> <column not-null="false" unique="false" name="`name`"/>
>>>>>> </property>
>>>>>> <list name="books" lazy="true"
>>>>>> cascade="merge,persist,save-update,lock,refresh">
>>>>>> <key update="true">
>>>>>> <column name="`book_author_e_id`" not-null="false"
>>>>>> unique="false"/>
>>>>>> </key>
>>>>>> <list-index column="`writer_books_idx`"/>
>>>>>> <one-to-many entity-name="Book"/>
>>>>>> </list>
>>>>>> </class>
>>>>>> </hibernate-mapping>
>>>>>>
>>>>>>
>>>>>> Martin Taal wrote:
>>>>>>> Alain,
>>>>>>> I am a bit mistified myself also, when you set a breakpoint here:
>>>>>>> BookImpl.eSet(BookImpl.java:309),
>>>>>>> what is the class of the object you get and what is the class
>>>>>>> instance to which the cast is tried?
>>>>>>>
>>>>>>> Which version of Teneo are you using?
>>>>>>> Can you post/send me the hbm mapping? (you can get it by doing
>>>>>>> dataStore.getMappingXML())
>>>>>>>
>>>>>>> gr. Martin
>>>>>>>
>>>>>>> Alain Picard wrote:
>>>>>>>> Martin,
>>>>>>>>
>>>>>>>> I just made the changes and did a clean build, started with
>>>>>>>> -clean, but to no avail.
>>>>>>>>
>>>>>>>> Any other idea?
>>>>>>>>
>>>>>>>> Alain
>>>>>>>>
>>>>>>>> Martin Taal wrote:
>>>>>>>>> Hi Alain,
>>>>>>>>> Can you try setting the buddy policy to dependent? Although it
>>>>>>>>> is less precise (classloading can take more time) it is the
>>>>>>>>> safest to try.
>>>>>>>>>
>>>>>>>>> gr. Martin
>>>>>>>>>
>>>>>>>>> Alain Picard wrote:
>>>>>>>>>> I am getting acquainted with Teneo and going through the
>>>>>>>>>> library editor example (after successfully doing the Tutorial1
>>>>>>>>>> part). I have been able to start the wizard on an empty
>>>>>>>>>> database and to create a library with a book and author.
>>>>>>>>>>
>>>>>>>>>> When I restart back from scratch, it attempts to load the
>>>>>>>>>> content of the db and fails with the following:
>>>>>>>>>> java.lang.ClassCastException:
>>>>>>>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>>>>>>>> org.eclipse.example.library.BookCategory
>>>>>>>>>> at
>>>>>>>>>> org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
>>>>>>>>>> at
>>>>>>>>>> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>>>>>>>>>>
>>>>>>>>>> at
>>>>>>>>>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>>>>>>>>>>
>>>>>>>>>> at
>>>>>>>>>> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>>>>>>>>>>
>>>>>>>>>> at
>>>>>>>>>> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
>>>>>>>>>>
>>>>>>>>>> at
>>>>>>>>>> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>>>>>>>>>>
>>>>>>>>>> .....etc
>>>>>>>>>>
>>>>>>>>>> This gives me the idea that I might be dealing with a
>>>>>>>>>> classloader problem, since my Hibernate jars are in a
>>>>>>>>>> different bundle. I have it's buddy policy set to registered
>>>>>>>>>> and all of the library projects have Eclipse-RegisterBuddy:
>>>>>>>>>> Shared_JARs (the bundle containing Hibernate).
>>>>>>>>>>
>>>>>>>>>> Does anyone has seen this before and have any clue how to fix it?
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>> Alain
>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Re: [Teneo] ClassCastException retrieving model [message #605059 is a reply to message #81193] Wed, 25 April 2007 18:35 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Alain,
Can you try setting the buddy policy to dependent? Although it is less precise (classloading can
take more time) it is the safest to try.

gr. Martin

Alain Picard wrote:
> I am getting acquainted with Teneo and going through the library editor
> example (after successfully doing the Tutorial1 part). I have been able
> to start the wizard on an empty database and to create a library with a
> book and author.
>
> When I restart back from scratch, it attempts to load the content of the
> db and fails with the following:
> java.lang.ClassCastException: org.eclipse.example.library.BookCategory
> cannot be cast to org.eclipse.example.library.BookCategory
> at org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
> at
> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>
> at
> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>
> at
> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>
> at
> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
> at
> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>
> .....etc
>
> This gives me the idea that I might be dealing with a classloader
> problem, since my Hibernate jars are in a different bundle. I have it's
> buddy policy set to registered and all of the library projects have
> Eclipse-RegisterBuddy: Shared_JARs (the bundle containing Hibernate).
>
> Does anyone has seen this before and have any clue how to fix it?
>
> Thanks
> Alain


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] ClassCastException retrieving model [message #605063 is a reply to message #81208] Wed, 25 April 2007 19:48 Go to previous message
Alain Picard is currently offline Alain PicardFriend
Messages: 235
Registered: July 2009
Senior Member
Martin,

I just made the changes and did a clean build, started with -clean, but
to no avail.

Any other idea?

Alain

Martin Taal wrote:
> Hi Alain,
> Can you try setting the buddy policy to dependent? Although it is less
> precise (classloading can take more time) it is the safest to try.
>
> gr. Martin
>
> Alain Picard wrote:
>> I am getting acquainted with Teneo and going through the library
>> editor example (after successfully doing the Tutorial1 part). I have
>> been able to start the wizard on an empty database and to create a
>> library with a book and author.
>>
>> When I restart back from scratch, it attempts to load the content of
>> the db and fails with the following:
>> java.lang.ClassCastException: org.eclipse.example.library.BookCategory
>> cannot be cast to org.eclipse.example.library.BookCategory
>> at org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
>> at
>> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>>
>> at
>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>>
>> at
>> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>>
>> at
>> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
>> at
>> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>>
>> .....etc
>>
>> This gives me the idea that I might be dealing with a classloader
>> problem, since my Hibernate jars are in a different bundle. I have
>> it's buddy policy set to registered and all of the library projects
>> have Eclipse-RegisterBuddy: Shared_JARs (the bundle containing
>> Hibernate).
>>
>> Does anyone has seen this before and have any clue how to fix it?
>>
>> Thanks
>> Alain
>
>
Re: [Teneo] ClassCastException retrieving model [message #605066 is a reply to message #81223] Wed, 25 April 2007 20:30 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Alain,
I am a bit mistified myself also, when you set a breakpoint here: BookImpl.eSet(BookImpl.java:309),
what is the class of the object you get and what is the class instance to which the cast is tried?

Which version of Teneo are you using?
Can you post/send me the hbm mapping? (you can get it by doing dataStore.getMappingXML())

gr. Martin

Alain Picard wrote:
> Martin,
>
> I just made the changes and did a clean build, started with -clean, but
> to no avail.
>
> Any other idea?
>
> Alain
>
> Martin Taal wrote:
>> Hi Alain,
>> Can you try setting the buddy policy to dependent? Although it is less
>> precise (classloading can take more time) it is the safest to try.
>>
>> gr. Martin
>>
>> Alain Picard wrote:
>>> I am getting acquainted with Teneo and going through the library
>>> editor example (after successfully doing the Tutorial1 part). I have
>>> been able to start the wizard on an empty database and to create a
>>> library with a book and author.
>>>
>>> When I restart back from scratch, it attempts to load the content of
>>> the db and fails with the following:
>>> java.lang.ClassCastException:
>>> org.eclipse.example.library.BookCategory cannot be cast to
>>> org.eclipse.example.library.BookCategory
>>> at org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
>>> at
>>> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>>>
>>> at
>>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>>>
>>> at
>>> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>>>
>>> at
>>> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
>>>
>>> at
>>> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>>>
>>> .....etc
>>>
>>> This gives me the idea that I might be dealing with a classloader
>>> problem, since my Hibernate jars are in a different bundle. I have
>>> it's buddy policy set to registered and all of the library projects
>>> have Eclipse-RegisterBuddy: Shared_JARs (the bundle containing
>>> Hibernate).
>>>
>>> Does anyone has seen this before and have any clue how to fix it?
>>>
>>> Thanks
>>> Alain
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] ClassCastException retrieving model [message #605079 is a reply to message #81237] Wed, 25 April 2007 22:19 Go to previous message
Alain Picard is currently offline Alain PicardFriend
Messages: 235
Registered: July 2009
Senior Member
Martin,

I get a org.eclipse.example.library.BookCategory and it is being cast to
BookCategory as the error mentioned:
java.lang.ClassCastException: org.eclipse.example.library.BookCategory
cannot be cast to org.eclipse.example.library.BookCategory

I am using the latest version of Teneo (0.8
emft-teneo-SDK-I200704230019) with EMF (emf-sdo-xsd-SDK-2.3.0M6) under
Eclipse 3.3M6

I am trying to get some trace info to get the class loader tree, but I
am still fighting that battle.

Thanks for your help.
Alain


Here is the mapping info:
<hibernate-mapping>
<class name="org.eclipse.example.library.impl.BookImpl"
entity-name="Book" abstract="false" lazy="false"
discriminator-value="Book" table="`book`">
<meta attribute="eclassName">Book</meta>
<meta
attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
<id type="long" name="e_id" column="e_id"
access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
<meta attribute="syntheticId">true</meta>
<generator class="native"/>
</id>
<discriminator column="`dtype`" type="string"/>
<version name="e_version" column="e_version"
access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
<meta attribute="syntheticVersion">true</meta>
</version>
<property name="title" lazy="false" insert="true" update="true"
not-null="false" unique="false" type="java.lang.String">
<column not-null="false" unique="false" name="`title`"/>
</property>
<property name="pages" lazy="false" insert="true" update="true"
not-null="false" unique="false" type="int">
<column not-null="false" unique="false" name="`pages`"/>
</property>
<property name="category" lazy="false" not-null="false" insert="true"
update="true" unique="false">
<column not-null="false" unique="false" name="`category`"/>
<type name="org.eclipse.emf.teneo.hibernate.mapping.ENumUserType" >
<param name="enumClass">org.eclipse.example.library.BookCategory</param >
</type>
</property>
<many-to-one name="author" entity-name="Writer"
cascade="merge,persist,save-update,lock,refresh" lazy="false"
insert="false" update="false" not-null="false">
<column not-null="false" unique="false" name="`book_author_e_id`"/>
</many-to-one>
</class>
<class name="org.eclipse.example.library.impl.LibraryImpl"
entity-name="Library" abstract="false" lazy="false"
discriminator-value="Library" table="`library`">
<meta attribute="eclassName">Library</meta>
<meta
attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
<id type="long" name="e_id" column="e_id"
access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
<meta attribute="syntheticId">true</meta>
<generator class="native"/>
</id>
<discriminator column="`dtype`" type="string"/>
<version name="e_version" column="e_version"
access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
<meta attribute="syntheticVersion">true</meta>
</version>
<property name="name" lazy="false" insert="true" update="true"
not-null="false" unique="false" type="java.lang.String">
<column not-null="false" unique="false" name="`name`"/>
</property>
<list name="writers" lazy="true" cascade="all,delete-orphan">
<key update="true">
<column name="`library_writers_e_id`" not-null="false" unique="false"/>
</key>
<list-index column="`library_writers_idx`"/>
<one-to-many entity-name="Writer"/>
</list>
<list name="books" lazy="true" cascade="all,delete-orphan">
<key update="true">
<column name="`library_books_e_id`" not-null="false" unique="false"/>
</key>
<list-index column="`library_books_idx`"/>
<one-to-many entity-name="Book"/>
</list>
</class>
<class name="org.eclipse.example.library.impl.WriterImpl"
entity-name="Writer" abstract="false" lazy="false"
discriminator-value="Writer" table="`writer`">
<meta attribute="eclassName">Writer</meta>
<meta
attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
<id type="long" name="e_id" column="e_id"
access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
<meta attribute="syntheticId">true</meta>
<generator class="native"/>
</id>
<discriminator column="`dtype`" type="string"/>
<version name="e_version" column="e_version"
access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
<meta attribute="syntheticVersion">true</meta>
</version>
<property name="name" lazy="false" insert="true" update="true"
not-null="false" unique="false" type="java.lang.String">
<column not-null="false" unique="false" name="`name`"/>
</property>
<list name="books" lazy="true"
cascade="merge,persist,save-update,lock,refresh">
<key update="true">
<column name="`book_author_e_id`" not-null="false" unique="false"/>
</key>
<list-index column="`writer_books_idx`"/>
<one-to-many entity-name="Book"/>
</list>
</class>
</hibernate-mapping>


Martin Taal wrote:
> Alain,
> I am a bit mistified myself also, when you set a breakpoint here:
> BookImpl.eSet(BookImpl.java:309),
> what is the class of the object you get and what is the class instance
> to which the cast is tried?
>
> Which version of Teneo are you using?
> Can you post/send me the hbm mapping? (you can get it by doing
> dataStore.getMappingXML())
>
> gr. Martin
>
> Alain Picard wrote:
>> Martin,
>>
>> I just made the changes and did a clean build, started with -clean,
>> but to no avail.
>>
>> Any other idea?
>>
>> Alain
>>
>> Martin Taal wrote:
>>> Hi Alain,
>>> Can you try setting the buddy policy to dependent? Although it is
>>> less precise (classloading can take more time) it is the safest to try.
>>>
>>> gr. Martin
>>>
>>> Alain Picard wrote:
>>>> I am getting acquainted with Teneo and going through the library
>>>> editor example (after successfully doing the Tutorial1 part). I have
>>>> been able to start the wizard on an empty database and to create a
>>>> library with a book and author.
>>>>
>>>> When I restart back from scratch, it attempts to load the content of
>>>> the db and fails with the following:
>>>> java.lang.ClassCastException:
>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>> org.eclipse.example.library.BookCategory
>>>> at
>>>> org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>>>>
>>>> at
>>>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>>>>
>>>> at
>>>> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>>>>
>>>> at
>>>> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
>>>>
>>>> at
>>>> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>>>>
>>>> .....etc
>>>>
>>>> This gives me the idea that I might be dealing with a classloader
>>>> problem, since my Hibernate jars are in a different bundle. I have
>>>> it's buddy policy set to registered and all of the library projects
>>>> have Eclipse-RegisterBuddy: Shared_JARs (the bundle containing
>>>> Hibernate).
>>>>
>>>> Does anyone has seen this before and have any clue how to fix it?
>>>>
>>>> Thanks
>>>> Alain
>>>
>>>
>
>
Re: [Teneo] ClassCastException retrieving model [message #605084 is a reply to message #81282] Thu, 26 April 2007 04:48 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Alain,
I am not sure why this does not work but I can give you some more background information for you to
look at. At your breakpoint in the BookImpl.eSet you can get the classloader from both the
BookCategory class used for the cast as well as the classloader (getClassLoader() method on the
class itself). The same can be done for the class of the passed object. In the debugger you can try
to walk through the classloader hierarchy to see if the two classloaders are related.

The (BookCategory) class of the passed object in the eSet is loaded in the EnumUserType class in the
setParameterValues method. This is done when you initialize the datastore. As a default teneo uses
the ContextClassLoaderStrategy (see org.eclipse.emf.teneo.classloader) which uses the following to
load the class:
Thread.currentThread().getContextClassLoader()

I do not know how/when the second classloader (which reads its own BookCategory) comes into play. To
analyse this it could help to put a static initializer block in the BookCategory class with a
breakpoint (or print the stack trace) and then see when this is executed (twice).

It seems that the initialization of the datastore uses a classloader which is not related to the
classloader which later reads the library model again for your plugins.

gr. Martin

Alain Picard wrote:
> Martin,
>
> I get a org.eclipse.example.library.BookCategory and it is being cast to
> BookCategory as the error mentioned:
> java.lang.ClassCastException: org.eclipse.example.library.BookCategory
> cannot be cast to org.eclipse.example.library.BookCategory
>
> I am using the latest version of Teneo (0.8
> emft-teneo-SDK-I200704230019) with EMF (emf-sdo-xsd-SDK-2.3.0M6) under
> Eclipse 3.3M6
>
> I am trying to get some trace info to get the class loader tree, but I
> am still fighting that battle.
>
> Thanks for your help.
> Alain
>
>
> Here is the mapping info:
> <hibernate-mapping>
> <class name="org.eclipse.example.library.impl.BookImpl"
> entity-name="Book" abstract="false" lazy="false"
> discriminator-value="Book" table="`book`">
> <meta attribute="eclassName">Book</meta>
> <meta
> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
> <id type="long" name="e_id" column="e_id"
> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>
> <meta attribute="syntheticId">true</meta>
> <generator class="native"/>
> </id>
> <discriminator column="`dtype`" type="string"/>
> <version name="e_version" column="e_version"
> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>
> <meta attribute="syntheticVersion">true</meta>
> </version>
> <property name="title" lazy="false" insert="true" update="true"
> not-null="false" unique="false" type="java.lang.String">
> <column not-null="false" unique="false" name="`title`"/>
> </property>
> <property name="pages" lazy="false" insert="true" update="true"
> not-null="false" unique="false" type="int">
> <column not-null="false" unique="false" name="`pages`"/>
> </property>
> <property name="category" lazy="false" not-null="false"
> insert="true" update="true" unique="false">
> <column not-null="false" unique="false" name="`category`"/>
> <type
> name="org.eclipse.emf.teneo.hibernate.mapping.ENumUserType" >
> <param
> name="enumClass">org.eclipse.example.library.BookCategory</param >
> </type>
> </property>
> <many-to-one name="author" entity-name="Writer"
> cascade="merge,persist,save-update,lock,refresh" lazy="false"
> insert="false" update="false" not-null="false">
> <column not-null="false" unique="false"
> name="`book_author_e_id`"/>
> </many-to-one>
> </class>
> <class name="org.eclipse.example.library.impl.LibraryImpl"
> entity-name="Library" abstract="false" lazy="false"
> discriminator-value="Library" table="`library`">
> <meta attribute="eclassName">Library</meta>
> <meta
> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
> <id type="long" name="e_id" column="e_id"
> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>
> <meta attribute="syntheticId">true</meta>
> <generator class="native"/>
> </id>
> <discriminator column="`dtype`" type="string"/>
> <version name="e_version" column="e_version"
> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>
> <meta attribute="syntheticVersion">true</meta>
> </version>
> <property name="name" lazy="false" insert="true" update="true"
> not-null="false" unique="false" type="java.lang.String">
> <column not-null="false" unique="false" name="`name`"/>
> </property>
> <list name="writers" lazy="true" cascade="all,delete-orphan">
> <key update="true">
> <column name="`library_writers_e_id`" not-null="false"
> unique="false"/>
> </key>
> <list-index column="`library_writers_idx`"/>
> <one-to-many entity-name="Writer"/>
> </list>
> <list name="books" lazy="true" cascade="all,delete-orphan">
> <key update="true">
> <column name="`library_books_e_id`" not-null="false"
> unique="false"/>
> </key>
> <list-index column="`library_books_idx`"/>
> <one-to-many entity-name="Book"/>
> </list>
> </class>
> <class name="org.eclipse.example.library.impl.WriterImpl"
> entity-name="Writer" abstract="false" lazy="false"
> discriminator-value="Writer" table="`writer`">
> <meta attribute="eclassName">Writer</meta>
> <meta
> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
> <id type="long" name="e_id" column="e_id"
> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>
> <meta attribute="syntheticId">true</meta>
> <generator class="native"/>
> </id>
> <discriminator column="`dtype`" type="string"/>
> <version name="e_version" column="e_version"
> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>
> <meta attribute="syntheticVersion">true</meta>
> </version>
> <property name="name" lazy="false" insert="true" update="true"
> not-null="false" unique="false" type="java.lang.String">
> <column not-null="false" unique="false" name="`name`"/>
> </property>
> <list name="books" lazy="true"
> cascade="merge,persist,save-update,lock,refresh">
> <key update="true">
> <column name="`book_author_e_id`" not-null="false"
> unique="false"/>
> </key>
> <list-index column="`writer_books_idx`"/>
> <one-to-many entity-name="Book"/>
> </list>
> </class>
> </hibernate-mapping>
>
>
> Martin Taal wrote:
>> Alain,
>> I am a bit mistified myself also, when you set a breakpoint here:
>> BookImpl.eSet(BookImpl.java:309),
>> what is the class of the object you get and what is the class instance
>> to which the cast is tried?
>>
>> Which version of Teneo are you using?
>> Can you post/send me the hbm mapping? (you can get it by doing
>> dataStore.getMappingXML())
>>
>> gr. Martin
>>
>> Alain Picard wrote:
>>> Martin,
>>>
>>> I just made the changes and did a clean build, started with -clean,
>>> but to no avail.
>>>
>>> Any other idea?
>>>
>>> Alain
>>>
>>> Martin Taal wrote:
>>>> Hi Alain,
>>>> Can you try setting the buddy policy to dependent? Although it is
>>>> less precise (classloading can take more time) it is the safest to try.
>>>>
>>>> gr. Martin
>>>>
>>>> Alain Picard wrote:
>>>>> I am getting acquainted with Teneo and going through the library
>>>>> editor example (after successfully doing the Tutorial1 part). I
>>>>> have been able to start the wizard on an empty database and to
>>>>> create a library with a book and author.
>>>>>
>>>>> When I restart back from scratch, it attempts to load the content
>>>>> of the db and fails with the following:
>>>>> java.lang.ClassCastException:
>>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>>> org.eclipse.example.library.BookCategory
>>>>> at
>>>>> org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>>>>>
>>>>> at
>>>>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>>>>>
>>>>> at
>>>>> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>>>>>
>>>>> at
>>>>> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
>>>>>
>>>>> at
>>>>> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>>>>>
>>>>> .....etc
>>>>>
>>>>> This gives me the idea that I might be dealing with a classloader
>>>>> problem, since my Hibernate jars are in a different bundle. I have
>>>>> it's buddy policy set to registered and all of the library projects
>>>>> have Eclipse-RegisterBuddy: Shared_JARs (the bundle containing
>>>>> Hibernate).
>>>>>
>>>>> Does anyone has seen this before and have any clue how to fix it?
>>>>>
>>>>> Thanks
>>>>> Alain
>>>>
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] ClassCastException retrieving model [message #605098 is a reply to message #81298] Thu, 26 April 2007 20:37 Go to previous message
Alain Picard is currently offline Alain PicardFriend
Messages: 235
Registered: July 2009
Senior Member
Martin,

Here is what I am getting (in order):
In static init of BookCategory.
CL:org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea

In ENumUserType with enumClassName of:
org.eclipse.example.library.BookCategory

then it goes to get the classForName:
Thread.getContextClassLoader() line: 1314 [local variables unavailable]
ContextClassLoaderStrategy.getClassLoader() line: 32
ClassLoaderResolver.getClassLoader() line: 59
ClassLoaderResolver.classForName(String) line: 51
ENumUserType.setParameterValues(Properties) line: 175

with Thread.getContextClassLoader() returning the following
contextClassLoader:
org.eclipse.core.runtime.internal.adaptor.ContextFinder@d82aff
with parent: sun.misc.Launcher$AppClassLoader@1a7bf11
with parent: sun.misc.Launcher$ExtClassLoader@1f12c4e
with parent: null

Then later in BookImpl eSet i get the following (where the CL matched
the one reported in the static constructor):
BookCaterogy CL:
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea
parent: org.eclipse.osgi.baseadaptor.BaseAdaptor$ParentClassLoader@16917ee
parent: null

The message in the BookCategory static constructor is only called once
at the beginning of this trace.

Also when you mentioned:
> In the debugger you can try to walk through the
> classloader hierarchy to see if the two classloaders are related.
Is there any way to walk the complete classloader hierarchy starting
from the root. What I am getting doesn't even agree on a root.

Thanks
Alain


Martin Taal wrote:
> Alain,
> I am not sure why this does not work but I can give you some more
> background information for you to look at. At your breakpoint in the
> BookImpl.eSet you can get the classloader from both the BookCategory
> class used for the cast as well as the classloader (getClassLoader()
> method on the class itself). The same can be done for the class of the
> passed object. In the debugger you can try to walk through the
> classloader hierarchy to see if the two classloaders are related.
>
> The (BookCategory) class of the passed object in the eSet is loaded in
> the EnumUserType class in the setParameterValues method. This is done
> when you initialize the datastore. As a default teneo uses the
> ContextClassLoaderStrategy (see org.eclipse.emf.teneo.classloader) which
> uses the following to load the class:
> Thread.currentThread().getContextClassLoader()
>
> I do not know how/when the second classloader (which reads its own
> BookCategory) comes into play. To analyse this it could help to put a
> static initializer block in the BookCategory class with a breakpoint (or
> print the stack trace) and then see when this is executed (twice).
>
> It seems that the initialization of the datastore uses a classloader
> which is not related to the classloader which later reads the library
> model again for your plugins.
>
> gr. Martin
>
> Alain Picard wrote:
>> Martin,
>>
>> I get a org.eclipse.example.library.BookCategory and it is being cast
>> to BookCategory as the error mentioned:
>> java.lang.ClassCastException: org.eclipse.example.library.BookCategory
>> cannot be cast to org.eclipse.example.library.BookCategory
>>
>> I am using the latest version of Teneo (0.8
>> emft-teneo-SDK-I200704230019) with EMF (emf-sdo-xsd-SDK-2.3.0M6) under
>> Eclipse 3.3M6
>>
>> I am trying to get some trace info to get the class loader tree, but I
>> am still fighting that battle.
>>
>> Thanks for your help.
>> Alain
>>
>>
>> Here is the mapping info:
>> <hibernate-mapping>
>> <class name="org.eclipse.example.library.impl.BookImpl"
>> entity-name="Book" abstract="false" lazy="false"
>> discriminator-value="Book" table="`book`">
>> <meta attribute="eclassName">Book</meta>
>> <meta
>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>> <id type="long" name="e_id" column="e_id"
>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>
>> <meta attribute="syntheticId">true</meta>
>> <generator class="native"/>
>> </id>
>> <discriminator column="`dtype`" type="string"/>
>> <version name="e_version" column="e_version"
>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>
>> <meta attribute="syntheticVersion">true</meta>
>> </version>
>> <property name="title" lazy="false" insert="true"
>> update="true" not-null="false" unique="false" type="java.lang.String">
>> <column not-null="false" unique="false" name="`title`"/>
>> </property>
>> <property name="pages" lazy="false" insert="true"
>> update="true" not-null="false" unique="false" type="int">
>> <column not-null="false" unique="false" name="`pages`"/>
>> </property>
>> <property name="category" lazy="false" not-null="false"
>> insert="true" update="true" unique="false">
>> <column not-null="false" unique="false" name="`category`"/>
>> <type
>> name="org.eclipse.emf.teneo.hibernate.mapping.ENumUserType" >
>> <param
>> name="enumClass">org.eclipse.example.library.BookCategory</param >
>> </type>
>> </property>
>> <many-to-one name="author" entity-name="Writer"
>> cascade="merge,persist,save-update,lock,refresh" lazy="false"
>> insert="false" update="false" not-null="false">
>> <column not-null="false" unique="false"
>> name="`book_author_e_id`"/>
>> </many-to-one>
>> </class>
>> <class name="org.eclipse.example.library.impl.LibraryImpl"
>> entity-name="Library" abstract="false" lazy="false"
>> discriminator-value="Library" table="`library`">
>> <meta attribute="eclassName">Library</meta>
>> <meta
>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>> <id type="long" name="e_id" column="e_id"
>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>
>> <meta attribute="syntheticId">true</meta>
>> <generator class="native"/>
>> </id>
>> <discriminator column="`dtype`" type="string"/>
>> <version name="e_version" column="e_version"
>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>
>> <meta attribute="syntheticVersion">true</meta>
>> </version>
>> <property name="name" lazy="false" insert="true" update="true"
>> not-null="false" unique="false" type="java.lang.String">
>> <column not-null="false" unique="false" name="`name`"/>
>> </property>
>> <list name="writers" lazy="true" cascade="all,delete-orphan">
>> <key update="true">
>> <column name="`library_writers_e_id`" not-null="false"
>> unique="false"/>
>> </key>
>> <list-index column="`library_writers_idx`"/>
>> <one-to-many entity-name="Writer"/>
>> </list>
>> <list name="books" lazy="true" cascade="all,delete-orphan">
>> <key update="true">
>> <column name="`library_books_e_id`" not-null="false"
>> unique="false"/>
>> </key>
>> <list-index column="`library_books_idx`"/>
>> <one-to-many entity-name="Book"/>
>> </list>
>> </class>
>> <class name="org.eclipse.example.library.impl.WriterImpl"
>> entity-name="Writer" abstract="false" lazy="false"
>> discriminator-value="Writer" table="`writer`">
>> <meta attribute="eclassName">Writer</meta>
>> <meta
>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>> <id type="long" name="e_id" column="e_id"
>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>
>> <meta attribute="syntheticId">true</meta>
>> <generator class="native"/>
>> </id>
>> <discriminator column="`dtype`" type="string"/>
>> <version name="e_version" column="e_version"
>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>
>> <meta attribute="syntheticVersion">true</meta>
>> </version>
>> <property name="name" lazy="false" insert="true" update="true"
>> not-null="false" unique="false" type="java.lang.String">
>> <column not-null="false" unique="false" name="`name`"/>
>> </property>
>> <list name="books" lazy="true"
>> cascade="merge,persist,save-update,lock,refresh">
>> <key update="true">
>> <column name="`book_author_e_id`" not-null="false"
>> unique="false"/>
>> </key>
>> <list-index column="`writer_books_idx`"/>
>> <one-to-many entity-name="Book"/>
>> </list>
>> </class>
>> </hibernate-mapping>
>>
>>
>> Martin Taal wrote:
>>> Alain,
>>> I am a bit mistified myself also, when you set a breakpoint here:
>>> BookImpl.eSet(BookImpl.java:309),
>>> what is the class of the object you get and what is the class
>>> instance to which the cast is tried?
>>>
>>> Which version of Teneo are you using?
>>> Can you post/send me the hbm mapping? (you can get it by doing
>>> dataStore.getMappingXML())
>>>
>>> gr. Martin
>>>
>>> Alain Picard wrote:
>>>> Martin,
>>>>
>>>> I just made the changes and did a clean build, started with -clean,
>>>> but to no avail.
>>>>
>>>> Any other idea?
>>>>
>>>> Alain
>>>>
>>>> Martin Taal wrote:
>>>>> Hi Alain,
>>>>> Can you try setting the buddy policy to dependent? Although it is
>>>>> less precise (classloading can take more time) it is the safest to
>>>>> try.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Alain Picard wrote:
>>>>>> I am getting acquainted with Teneo and going through the library
>>>>>> editor example (after successfully doing the Tutorial1 part). I
>>>>>> have been able to start the wizard on an empty database and to
>>>>>> create a library with a book and author.
>>>>>>
>>>>>> When I restart back from scratch, it attempts to load the content
>>>>>> of the db and fails with the following:
>>>>>> java.lang.ClassCastException:
>>>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>>>> org.eclipse.example.library.BookCategory
>>>>>> at
>>>>>> org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
>>>>>> at
>>>>>> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>>>>>>
>>>>>> .....etc
>>>>>>
>>>>>> This gives me the idea that I might be dealing with a classloader
>>>>>> problem, since my Hibernate jars are in a different bundle. I have
>>>>>> it's buddy policy set to registered and all of the library
>>>>>> projects have Eclipse-RegisterBuddy: Shared_JARs (the bundle
>>>>>> containing Hibernate).
>>>>>>
>>>>>> Does anyone has seen this before and have any clue how to fix it?
>>>>>>
>>>>>> Thanks
>>>>>> Alain
>>>>>
>>>>>
>>>
>>>
>
>
Re: [Teneo] ClassCastException retrieving model [message #605109 is a reply to message #81343] Fri, 27 April 2007 12:33 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Alain,
Hmm where do you initialise the datastore (in which plugin)?

Teneo can be set to use another classloader you can do this by calling the method:
ClassLoaderResolver.setClassLoaderStrategy(ClassLoaderStrate gy classLoaderStrategy)
with your own ClassLoaderStrategy before initializing the datastore.

The ClassLoaderStrategy is a simple interface which returns the classloader which you want to use.

As a default Teneo uses the ContextClassLoaderStrategy but there is also the
ClassClassLoaderStrategy which uses the classloader of the calling class.

gr. Martin

Alain Picard wrote:
> Martin,
>
> Here is what I am getting (in order):
> In static init of BookCategory.
> CL:org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea
>
> In ENumUserType with enumClassName of:
> org.eclipse.example.library.BookCategory
>
> then it goes to get the classForName:
> Thread.getContextClassLoader() line: 1314 [local variables unavailable]
> ContextClassLoaderStrategy.getClassLoader() line: 32
> ClassLoaderResolver.getClassLoader() line: 59
> ClassLoaderResolver.classForName(String) line: 51
> ENumUserType.setParameterValues(Properties) line: 175
>
> with Thread.getContextClassLoader() returning the following
> contextClassLoader:
> org.eclipse.core.runtime.internal.adaptor.ContextFinder@d82aff
> with parent: sun.misc.Launcher$AppClassLoader@1a7bf11
> with parent: sun.misc.Launcher$ExtClassLoader@1f12c4e
> with parent: null
>
> Then later in BookImpl eSet i get the following (where the CL matched
> the one reported in the static constructor):
> BookCaterogy CL:
> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea
> parent: org.eclipse.osgi.baseadaptor.BaseAdaptor$ParentClassLoader@16917ee
> parent: null
>
> The message in the BookCategory static constructor is only called once
> at the beginning of this trace.
>
> Also when you mentioned:
> > In the debugger you can try to walk through the
> > classloader hierarchy to see if the two classloaders are related.
> Is there any way to walk the complete classloader hierarchy starting
> from the root. What I am getting doesn't even agree on a root.
>
> Thanks
> Alain
>
>
> Martin Taal wrote:
>> Alain,
>> I am not sure why this does not work but I can give you some more
>> background information for you to look at. At your breakpoint in the
>> BookImpl.eSet you can get the classloader from both the BookCategory
>> class used for the cast as well as the classloader (getClassLoader()
>> method on the class itself). The same can be done for the class of the
>> passed object. In the debugger you can try to walk through the
>> classloader hierarchy to see if the two classloaders are related.
>>
>> The (BookCategory) class of the passed object in the eSet is loaded in
>> the EnumUserType class in the setParameterValues method. This is done
>> when you initialize the datastore. As a default teneo uses the
>> ContextClassLoaderStrategy (see org.eclipse.emf.teneo.classloader)
>> which uses the following to load the class:
>> Thread.currentThread().getContextClassLoader()
>>
>> I do not know how/when the second classloader (which reads its own
>> BookCategory) comes into play. To analyse this it could help to put a
>> static initializer block in the BookCategory class with a breakpoint
>> (or print the stack trace) and then see when this is executed (twice).
>>
>> It seems that the initialization of the datastore uses a classloader
>> which is not related to the classloader which later reads the library
>> model again for your plugins.
>>
>> gr. Martin
>>
>> Alain Picard wrote:
>>> Martin,
>>>
>>> I get a org.eclipse.example.library.BookCategory and it is being cast
>>> to BookCategory as the error mentioned:
>>> java.lang.ClassCastException:
>>> org.eclipse.example.library.BookCategory cannot be cast to
>>> org.eclipse.example.library.BookCategory
>>>
>>> I am using the latest version of Teneo (0.8
>>> emft-teneo-SDK-I200704230019) with EMF (emf-sdo-xsd-SDK-2.3.0M6)
>>> under Eclipse 3.3M6
>>>
>>> I am trying to get some trace info to get the class loader tree, but
>>> I am still fighting that battle.
>>>
>>> Thanks for your help.
>>> Alain
>>>
>>>
>>> Here is the mapping info:
>>> <hibernate-mapping>
>>> <class name="org.eclipse.example.library.impl.BookImpl"
>>> entity-name="Book" abstract="false" lazy="false"
>>> discriminator-value="Book" table="`book`">
>>> <meta attribute="eclassName">Book</meta>
>>> <meta
>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>> <id type="long" name="e_id" column="e_id"
>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>
>>> <meta attribute="syntheticId">true</meta>
>>> <generator class="native"/>
>>> </id>
>>> <discriminator column="`dtype`" type="string"/>
>>> <version name="e_version" column="e_version"
>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>
>>> <meta attribute="syntheticVersion">true</meta>
>>> </version>
>>> <property name="title" lazy="false" insert="true"
>>> update="true" not-null="false" unique="false" type="java.lang.String">
>>> <column not-null="false" unique="false" name="`title`"/>
>>> </property>
>>> <property name="pages" lazy="false" insert="true"
>>> update="true" not-null="false" unique="false" type="int">
>>> <column not-null="false" unique="false" name="`pages`"/>
>>> </property>
>>> <property name="category" lazy="false" not-null="false"
>>> insert="true" update="true" unique="false">
>>> <column not-null="false" unique="false" name="`category`"/>
>>> <type
>>> name="org.eclipse.emf.teneo.hibernate.mapping.ENumUserType" >
>>> <param
>>> name="enumClass">org.eclipse.example.library.BookCategory</param >
>>> </type>
>>> </property>
>>> <many-to-one name="author" entity-name="Writer"
>>> cascade="merge,persist,save-update,lock,refresh" lazy="false"
>>> insert="false" update="false" not-null="false">
>>> <column not-null="false" unique="false"
>>> name="`book_author_e_id`"/>
>>> </many-to-one>
>>> </class>
>>> <class name="org.eclipse.example.library.impl.LibraryImpl"
>>> entity-name="Library" abstract="false" lazy="false"
>>> discriminator-value="Library" table="`library`">
>>> <meta attribute="eclassName">Library</meta>
>>> <meta
>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>> <id type="long" name="e_id" column="e_id"
>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>
>>> <meta attribute="syntheticId">true</meta>
>>> <generator class="native"/>
>>> </id>
>>> <discriminator column="`dtype`" type="string"/>
>>> <version name="e_version" column="e_version"
>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>
>>> <meta attribute="syntheticVersion">true</meta>
>>> </version>
>>> <property name="name" lazy="false" insert="true"
>>> update="true" not-null="false" unique="false" type="java.lang.String">
>>> <column not-null="false" unique="false" name="`name`"/>
>>> </property>
>>> <list name="writers" lazy="true" cascade="all,delete-orphan">
>>> <key update="true">
>>> <column name="`library_writers_e_id`"
>>> not-null="false" unique="false"/>
>>> </key>
>>> <list-index column="`library_writers_idx`"/>
>>> <one-to-many entity-name="Writer"/>
>>> </list>
>>> <list name="books" lazy="true" cascade="all,delete-orphan">
>>> <key update="true">
>>> <column name="`library_books_e_id`" not-null="false"
>>> unique="false"/>
>>> </key>
>>> <list-index column="`library_books_idx`"/>
>>> <one-to-many entity-name="Book"/>
>>> </list>
>>> </class>
>>> <class name="org.eclipse.example.library.impl.WriterImpl"
>>> entity-name="Writer" abstract="false" lazy="false"
>>> discriminator-value="Writer" table="`writer`">
>>> <meta attribute="eclassName">Writer</meta>
>>> <meta
>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>> <id type="long" name="e_id" column="e_id"
>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>
>>> <meta attribute="syntheticId">true</meta>
>>> <generator class="native"/>
>>> </id>
>>> <discriminator column="`dtype`" type="string"/>
>>> <version name="e_version" column="e_version"
>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>
>>> <meta attribute="syntheticVersion">true</meta>
>>> </version>
>>> <property name="name" lazy="false" insert="true"
>>> update="true" not-null="false" unique="false" type="java.lang.String">
>>> <column not-null="false" unique="false" name="`name`"/>
>>> </property>
>>> <list name="books" lazy="true"
>>> cascade="merge,persist,save-update,lock,refresh">
>>> <key update="true">
>>> <column name="`book_author_e_id`" not-null="false"
>>> unique="false"/>
>>> </key>
>>> <list-index column="`writer_books_idx`"/>
>>> <one-to-many entity-name="Book"/>
>>> </list>
>>> </class>
>>> </hibernate-mapping>
>>>
>>>
>>> Martin Taal wrote:
>>>> Alain,
>>>> I am a bit mistified myself also, when you set a breakpoint here:
>>>> BookImpl.eSet(BookImpl.java:309),
>>>> what is the class of the object you get and what is the class
>>>> instance to which the cast is tried?
>>>>
>>>> Which version of Teneo are you using?
>>>> Can you post/send me the hbm mapping? (you can get it by doing
>>>> dataStore.getMappingXML())
>>>>
>>>> gr. Martin
>>>>
>>>> Alain Picard wrote:
>>>>> Martin,
>>>>>
>>>>> I just made the changes and did a clean build, started with -clean,
>>>>> but to no avail.
>>>>>
>>>>> Any other idea?
>>>>>
>>>>> Alain
>>>>>
>>>>> Martin Taal wrote:
>>>>>> Hi Alain,
>>>>>> Can you try setting the buddy policy to dependent? Although it is
>>>>>> less precise (classloading can take more time) it is the safest to
>>>>>> try.
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Alain Picard wrote:
>>>>>>> I am getting acquainted with Teneo and going through the library
>>>>>>> editor example (after successfully doing the Tutorial1 part). I
>>>>>>> have been able to start the wizard on an empty database and to
>>>>>>> create a library with a book and author.
>>>>>>>
>>>>>>> When I restart back from scratch, it attempts to load the content
>>>>>>> of the db and fails with the following:
>>>>>>> java.lang.ClassCastException:
>>>>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>>>>> org.eclipse.example.library.BookCategory
>>>>>>> at
>>>>>>> org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
>>>>>>> at
>>>>>>> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>>>>>>>
>>>>>>> at
>>>>>>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>>>>>>>
>>>>>>> at
>>>>>>> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>>>>>>>
>>>>>>> at
>>>>>>> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
>>>>>>>
>>>>>>> at
>>>>>>> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>>>>>>>
>>>>>>> .....etc
>>>>>>>
>>>>>>> This gives me the idea that I might be dealing with a classloader
>>>>>>> problem, since my Hibernate jars are in a different bundle. I
>>>>>>> have it's buddy policy set to registered and all of the library
>>>>>>> projects have Eclipse-RegisterBuddy: Shared_JARs (the bundle
>>>>>>> containing Hibernate).
>>>>>>>
>>>>>>> Does anyone has seen this before and have any clue how to fix it?
>>>>>>>
>>>>>>> Thanks
>>>>>>> Alain
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] ClassCastException retrieving model [message #605123 is a reply to message #81379] Sun, 29 April 2007 22:32 Go to previous message
Alain Picard is currently offline Alain PicardFriend
Messages: 235
Registered: July 2009
Senior Member
Martin,

Finally got it figured out.

I had to hack the java.lang.ClassLoader to implement a registry
( http://www.javaworld.com/javaworld/javaqa/2003-07/02-qa-0725 -classsrc2.html)
in order to understand what was happening. (Many other failed attempts
before)

Here is what I got:
[org.eclipse.example.library.BookCategory]:
loaded by
[org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader(org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@1201ad7)]
from
[file:/C:/eclipse/workspace/library/bin/org/eclipse/example/ library/BookCategory.class]

and then:
[org.eclipse.example.library.BookCategory]:
loaded by
[org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader(org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@1e7258e)]
from
[jar:file:/C:/eclipse/products/emft-teneo-ex-7423/eclipse/pl ugins/org.eclipse.emf.teneo.tutorial_0.8.0.v200704230019.jar !/org/eclipse/example/library/BookCategory.class]


Guess I had the example jar installed and getting in the way from my
original library project and that was also the reason i could only see 1
call to the static block in BookCategory.

Now I need to understand why I am getting a large number of empty "My
Library" under the single truly populated one.

Do you have any clue?

Thanks
Alain



Martin Taal wrote:
> Hi Alain,
> Hmm where do you initialise the datastore (in which plugin)?
>
> Teneo can be set to use another classloader you can do this by calling
> the method:
> ClassLoaderResolver.setClassLoaderStrategy(ClassLoaderStrate gy
> classLoaderStrategy)
> with your own ClassLoaderStrategy before initializing the datastore.
>
> The ClassLoaderStrategy is a simple interface which returns the
> classloader which you want to use.
>
> As a default Teneo uses the ContextClassLoaderStrategy but there is also
> the ClassClassLoaderStrategy which uses the classloader of the calling
> class.
>
> gr. Martin
>
> Alain Picard wrote:
>> Martin,
>>
>> Here is what I am getting (in order):
>> In static init of BookCategory.
>> CL:org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea
>>
>> In ENumUserType with enumClassName of:
>> org.eclipse.example.library.BookCategory
>>
>> then it goes to get the classForName:
>> Thread.getContextClassLoader() line: 1314 [local variables
>> unavailable] ContextClassLoaderStrategy.getClassLoader() line: 32
>> ClassLoaderResolver.getClassLoader() line: 59
>> ClassLoaderResolver.classForName(String) line: 51
>> ENumUserType.setParameterValues(Properties) line: 175
>> with Thread.getContextClassLoader() returning the following
>> contextClassLoader:
>> org.eclipse.core.runtime.internal.adaptor.ContextFinder@d82aff
>> with parent: sun.misc.Launcher$AppClassLoader@1a7bf11
>> with parent: sun.misc.Launcher$ExtClassLoader@1f12c4e
>> with parent: null
>>
>> Then later in BookImpl eSet i get the following (where the CL matched
>> the one reported in the static constructor):
>> BookCaterogy CL:
>> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea
>> parent:
>> org.eclipse.osgi.baseadaptor.BaseAdaptor$ParentClassLoader@16917ee
>> parent: null
>>
>> The message in the BookCategory static constructor is only called once
>> at the beginning of this trace.
>>
>> Also when you mentioned:
>> > In the debugger you can try to walk through the
>> > classloader hierarchy to see if the two classloaders are related.
>> Is there any way to walk the complete classloader hierarchy starting
>> from the root. What I am getting doesn't even agree on a root.
>>
>> Thanks
>> Alain
>>
>>
>> Martin Taal wrote:
>>> Alain,
>>> I am not sure why this does not work but I can give you some more
>>> background information for you to look at. At your breakpoint in the
>>> BookImpl.eSet you can get the classloader from both the BookCategory
>>> class used for the cast as well as the classloader (getClassLoader()
>>> method on the class itself). The same can be done for the class of
>>> the passed object. In the debugger you can try to walk through the
>>> classloader hierarchy to see if the two classloaders are related.
>>>
>>> The (BookCategory) class of the passed object in the eSet is loaded
>>> in the EnumUserType class in the setParameterValues method. This is
>>> done when you initialize the datastore. As a default teneo uses the
>>> ContextClassLoaderStrategy (see org.eclipse.emf.teneo.classloader)
>>> which uses the following to load the class:
>>> Thread.currentThread().getContextClassLoader()
>>>
>>> I do not know how/when the second classloader (which reads its own
>>> BookCategory) comes into play. To analyse this it could help to put a
>>> static initializer block in the BookCategory class with a breakpoint
>>> (or print the stack trace) and then see when this is executed (twice).
>>>
>>> It seems that the initialization of the datastore uses a classloader
>>> which is not related to the classloader which later reads the library
>>> model again for your plugins.
>>>
>>> gr. Martin
>>>
>>> Alain Picard wrote:
>>>> Martin,
>>>>
>>>> I get a org.eclipse.example.library.BookCategory and it is being
>>>> cast to BookCategory as the error mentioned:
>>>> java.lang.ClassCastException:
>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>> org.eclipse.example.library.BookCategory
>>>>
>>>> I am using the latest version of Teneo (0.8
>>>> emft-teneo-SDK-I200704230019) with EMF (emf-sdo-xsd-SDK-2.3.0M6)
>>>> under Eclipse 3.3M6
>>>>
>>>> I am trying to get some trace info to get the class loader tree, but
>>>> I am still fighting that battle.
>>>>
>>>> Thanks for your help.
>>>> Alain
>>>>
>>>>
>>>> Here is the mapping info:
>>>> <hibernate-mapping>
>>>> <class name="org.eclipse.example.library.impl.BookImpl"
>>>> entity-name="Book" abstract="false" lazy="false"
>>>> discriminator-value="Book" table="`book`">
>>>> <meta attribute="eclassName">Book</meta>
>>>> <meta
>>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>>> <id type="long" name="e_id" column="e_id"
>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>
>>>> <meta attribute="syntheticId">true</meta>
>>>> <generator class="native"/>
>>>> </id>
>>>> <discriminator column="`dtype`" type="string"/>
>>>> <version name="e_version" column="e_version"
>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>>
>>>> <meta attribute="syntheticVersion">true</meta>
>>>> </version>
>>>> <property name="title" lazy="false" insert="true"
>>>> update="true" not-null="false" unique="false" type="java.lang.String">
>>>> <column not-null="false" unique="false" name="`title`"/>
>>>> </property>
>>>> <property name="pages" lazy="false" insert="true"
>>>> update="true" not-null="false" unique="false" type="int">
>>>> <column not-null="false" unique="false" name="`pages`"/>
>>>> </property>
>>>> <property name="category" lazy="false" not-null="false"
>>>> insert="true" update="true" unique="false">
>>>> <column not-null="false" unique="false" name="`category`"/>
>>>> <type
>>>> name="org.eclipse.emf.teneo.hibernate.mapping.ENumUserType" >
>>>> <param
>>>> name="enumClass">org.eclipse.example.library.BookCategory</param >
>>>> </type>
>>>> </property>
>>>> <many-to-one name="author" entity-name="Writer"
>>>> cascade="merge,persist,save-update,lock,refresh" lazy="false"
>>>> insert="false" update="false" not-null="false">
>>>> <column not-null="false" unique="false"
>>>> name="`book_author_e_id`"/>
>>>> </many-to-one>
>>>> </class>
>>>> <class name="org.eclipse.example.library.impl.LibraryImpl"
>>>> entity-name="Library" abstract="false" lazy="false"
>>>> discriminator-value="Library" table="`library`">
>>>> <meta attribute="eclassName">Library</meta>
>>>> <meta
>>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>>> <id type="long" name="e_id" column="e_id"
>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>
>>>> <meta attribute="syntheticId">true</meta>
>>>> <generator class="native"/>
>>>> </id>
>>>> <discriminator column="`dtype`" type="string"/>
>>>> <version name="e_version" column="e_version"
>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>>
>>>> <meta attribute="syntheticVersion">true</meta>
>>>> </version>
>>>> <property name="name" lazy="false" insert="true"
>>>> update="true" not-null="false" unique="false" type="java.lang.String">
>>>> <column not-null="false" unique="false" name="`name`"/>
>>>> </property>
>>>> <list name="writers" lazy="true" cascade="all,delete-orphan">
>>>> <key update="true">
>>>> <column name="`library_writers_e_id`"
>>>> not-null="false" unique="false"/>
>>>> </key>
>>>> <list-index column="`library_writers_idx`"/>
>>>> <one-to-many entity-name="Writer"/>
>>>> </list>
>>>> <list name="books" lazy="true" cascade="all,delete-orphan">
>>>> <key update="true">
>>>> <column name="`library_books_e_id`" not-null="false"
>>>> unique="false"/>
>>>> </key>
>>>> <list-index column="`library_books_idx`"/>
>>>> <one-to-many entity-name="Book"/>
>>>> </list>
>>>> </class>
>>>> <class name="org.eclipse.example.library.impl.WriterImpl"
>>>> entity-name="Writer" abstract="false" lazy="false"
>>>> discriminator-value="Writer" table="`writer`">
>>>> <meta attribute="eclassName">Writer</meta>
>>>> <meta
>>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>>> <id type="long" name="e_id" column="e_id"
>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>
>>>> <meta attribute="syntheticId">true</meta>
>>>> <generator class="native"/>
>>>> </id>
>>>> <discriminator column="`dtype`" type="string"/>
>>>> <version name="e_version" column="e_version"
>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>>
>>>> <meta attribute="syntheticVersion">true</meta>
>>>> </version>
>>>> <property name="name" lazy="false" insert="true"
>>>> update="true" not-null="false" unique="false" type="java.lang.String">
>>>> <column not-null="false" unique="false" name="`name`"/>
>>>> </property>
>>>> <list name="books" lazy="true"
>>>> cascade="merge,persist,save-update,lock,refresh">
>>>> <key update="true">
>>>> <column name="`book_author_e_id`" not-null="false"
>>>> unique="false"/>
>>>> </key>
>>>> <list-index column="`writer_books_idx`"/>
>>>> <one-to-many entity-name="Book"/>
>>>> </list>
>>>> </class>
>>>> </hibernate-mapping>
>>>>
>>>>
>>>> Martin Taal wrote:
>>>>> Alain,
>>>>> I am a bit mistified myself also, when you set a breakpoint here:
>>>>> BookImpl.eSet(BookImpl.java:309),
>>>>> what is the class of the object you get and what is the class
>>>>> instance to which the cast is tried?
>>>>>
>>>>> Which version of Teneo are you using?
>>>>> Can you post/send me the hbm mapping? (you can get it by doing
>>>>> dataStore.getMappingXML())
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Alain Picard wrote:
>>>>>> Martin,
>>>>>>
>>>>>> I just made the changes and did a clean build, started with
>>>>>> -clean, but to no avail.
>>>>>>
>>>>>> Any other idea?
>>>>>>
>>>>>> Alain
>>>>>>
>>>>>> Martin Taal wrote:
>>>>>>> Hi Alain,
>>>>>>> Can you try setting the buddy policy to dependent? Although it is
>>>>>>> less precise (classloading can take more time) it is the safest
>>>>>>> to try.
>>>>>>>
>>>>>>> gr. Martin
>>>>>>>
>>>>>>> Alain Picard wrote:
>>>>>>>> I am getting acquainted with Teneo and going through the library
>>>>>>>> editor example (after successfully doing the Tutorial1 part). I
>>>>>>>> have been able to start the wizard on an empty database and to
>>>>>>>> create a library with a book and author.
>>>>>>>>
>>>>>>>> When I restart back from scratch, it attempts to load the
>>>>>>>> content of the db and fails with the following:
>>>>>>>> java.lang.ClassCastException:
>>>>>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>>>>>> org.eclipse.example.library.BookCategory
>>>>>>>> at
>>>>>>>> org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
>>>>>>>> at
>>>>>>>> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>>>>>>>>
>>>>>>>> at
>>>>>>>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>>>>>>>>
>>>>>>>> at
>>>>>>>> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>>>>>>>>
>>>>>>>> at
>>>>>>>> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
>>>>>>>>
>>>>>>>> at
>>>>>>>> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>>>>>>>>
>>>>>>>> .....etc
>>>>>>>>
>>>>>>>> This gives me the idea that I might be dealing with a
>>>>>>>> classloader problem, since my Hibernate jars are in a different
>>>>>>>> bundle. I have it's buddy policy set to registered and all of
>>>>>>>> the library projects have Eclipse-RegisterBuddy: Shared_JARs
>>>>>>>> (the bundle containing Hibernate).
>>>>>>>>
>>>>>>>> Does anyone has seen this before and have any clue how to fix it?
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>> Alain
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Re: [Teneo] ClassCastException retrieving model [message #605130 is a reply to message #81436] Mon, 30 April 2007 07:39 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Alain,
Thanks for the link, interesting article. It is a pity that java does not make this easier in the
standard sdk.

I am not sure what you do so I can not really answer the question why you get many empty libraries.
Maybe it is related to code which automatically creates a root object (a library) to prevent the
database from being empty (just guessing here).

gr. Martin

Alain Picard wrote:
> Martin,
>
> Finally got it figured out.
>
> I had to hack the java.lang.ClassLoader to implement a registry
> ( http://www.javaworld.com/javaworld/javaqa/2003-07/02-qa-0725 -classsrc2.html)
> in order to understand what was happening. (Many other failed attempts
> before)
>
> Here is what I got:
> [org.eclipse.example.library.BookCategory]:
> loaded by
> [org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader(org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@1201ad7)]
>
> from
> [file:/C:/eclipse/workspace/library/bin/org/eclipse/example/ library/BookCategory.class]
>
>
> and then:
> [org.eclipse.example.library.BookCategory]:
> loaded by
> [org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader(org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@1e7258e)]
>
> from
> [jar:file:/C:/eclipse/products/emft-teneo-ex-7423/eclipse/pl ugins/org.eclipse.emf.teneo.tutorial_0.8.0.v200704230019.jar !/org/eclipse/example/library/BookCategory.class]
>
>
>
> Guess I had the example jar installed and getting in the way from my
> original library project and that was also the reason i could only see 1
> call to the static block in BookCategory.
>
> Now I need to understand why I am getting a large number of empty "My
> Library" under the single truly populated one.
>
> Do you have any clue?
>
> Thanks
> Alain
>
>
>
> Martin Taal wrote:
>> Hi Alain,
>> Hmm where do you initialise the datastore (in which plugin)?
>>
>> Teneo can be set to use another classloader you can do this by calling
>> the method:
>> ClassLoaderResolver.setClassLoaderStrategy(ClassLoaderStrate gy
>> classLoaderStrategy)
>> with your own ClassLoaderStrategy before initializing the datastore.
>>
>> The ClassLoaderStrategy is a simple interface which returns the
>> classloader which you want to use.
>>
>> As a default Teneo uses the ContextClassLoaderStrategy but there is
>> also the ClassClassLoaderStrategy which uses the classloader of the
>> calling class.
>>
>> gr. Martin
>>
>> Alain Picard wrote:
>>> Martin,
>>>
>>> Here is what I am getting (in order):
>>> In static init of BookCategory.
>>> CL:org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea
>>>
>>> In ENumUserType with enumClassName of:
>>> org.eclipse.example.library.BookCategory
>>>
>>> then it goes to get the classForName:
>>> Thread.getContextClassLoader() line: 1314 [local variables
>>> unavailable] ContextClassLoaderStrategy.getClassLoader() line: 32
>>> ClassLoaderResolver.getClassLoader() line: 59
>>> ClassLoaderResolver.classForName(String) line: 51
>>> ENumUserType.setParameterValues(Properties) line: 175 with
>>> Thread.getContextClassLoader() returning the following
>>> contextClassLoader:
>>> org.eclipse.core.runtime.internal.adaptor.ContextFinder@d82aff
>>> with parent: sun.misc.Launcher$AppClassLoader@1a7bf11
>>> with parent: sun.misc.Launcher$ExtClassLoader@1f12c4e
>>> with parent: null
>>>
>>> Then later in BookImpl eSet i get the following (where the CL matched
>>> the one reported in the static constructor):
>>> BookCaterogy CL:
>>> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea
>>> parent:
>>> org.eclipse.osgi.baseadaptor.BaseAdaptor$ParentClassLoader@16917ee
>>> parent: null
>>>
>>> The message in the BookCategory static constructor is only called
>>> once at the beginning of this trace.
>>>
>>> Also when you mentioned:
>>> > In the debugger you can try to walk through the
>>> > classloader hierarchy to see if the two classloaders are related.
>>> Is there any way to walk the complete classloader hierarchy starting
>>> from the root. What I am getting doesn't even agree on a root.
>>>
>>> Thanks
>>> Alain
>>>
>>>
>>> Martin Taal wrote:
>>>> Alain,
>>>> I am not sure why this does not work but I can give you some more
>>>> background information for you to look at. At your breakpoint in the
>>>> BookImpl.eSet you can get the classloader from both the BookCategory
>>>> class used for the cast as well as the classloader (getClassLoader()
>>>> method on the class itself). The same can be done for the class of
>>>> the passed object. In the debugger you can try to walk through the
>>>> classloader hierarchy to see if the two classloaders are related.
>>>>
>>>> The (BookCategory) class of the passed object in the eSet is loaded
>>>> in the EnumUserType class in the setParameterValues method. This is
>>>> done when you initialize the datastore. As a default teneo uses the
>>>> ContextClassLoaderStrategy (see org.eclipse.emf.teneo.classloader)
>>>> which uses the following to load the class:
>>>> Thread.currentThread().getContextClassLoader()
>>>>
>>>> I do not know how/when the second classloader (which reads its own
>>>> BookCategory) comes into play. To analyse this it could help to put
>>>> a static initializer block in the BookCategory class with a
>>>> breakpoint (or print the stack trace) and then see when this is
>>>> executed (twice).
>>>>
>>>> It seems that the initialization of the datastore uses a classloader
>>>> which is not related to the classloader which later reads the
>>>> library model again for your plugins.
>>>>
>>>> gr. Martin
>>>>
>>>> Alain Picard wrote:
>>>>> Martin,
>>>>>
>>>>> I get a org.eclipse.example.library.BookCategory and it is being
>>>>> cast to BookCategory as the error mentioned:
>>>>> java.lang.ClassCastException:
>>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>>> org.eclipse.example.library.BookCategory
>>>>>
>>>>> I am using the latest version of Teneo (0.8
>>>>> emft-teneo-SDK-I200704230019) with EMF (emf-sdo-xsd-SDK-2.3.0M6)
>>>>> under Eclipse 3.3M6
>>>>>
>>>>> I am trying to get some trace info to get the class loader tree,
>>>>> but I am still fighting that battle.
>>>>>
>>>>> Thanks for your help.
>>>>> Alain
>>>>>
>>>>>
>>>>> Here is the mapping info:
>>>>> <hibernate-mapping>
>>>>> <class name="org.eclipse.example.library.impl.BookImpl"
>>>>> entity-name="Book" abstract="false" lazy="false"
>>>>> discriminator-value="Book" table="`book`">
>>>>> <meta attribute="eclassName">Book</meta>
>>>>> <meta
>>>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>>>> <id type="long" name="e_id" column="e_id"
>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>>
>>>>> <meta attribute="syntheticId">true</meta>
>>>>> <generator class="native"/>
>>>>> </id>
>>>>> <discriminator column="`dtype`" type="string"/>
>>>>> <version name="e_version" column="e_version"
>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>>>
>>>>> <meta attribute="syntheticVersion">true</meta>
>>>>> </version>
>>>>> <property name="title" lazy="false" insert="true"
>>>>> update="true" not-null="false" unique="false" type="java.lang.String">
>>>>> <column not-null="false" unique="false" name="`title`"/>
>>>>> </property>
>>>>> <property name="pages" lazy="false" insert="true"
>>>>> update="true" not-null="false" unique="false" type="int">
>>>>> <column not-null="false" unique="false" name="`pages`"/>
>>>>> </property>
>>>>> <property name="category" lazy="false" not-null="false"
>>>>> insert="true" update="true" unique="false">
>>>>> <column not-null="false" unique="false"
>>>>> name="`category`"/>
>>>>> <type
>>>>> name="org.eclipse.emf.teneo.hibernate.mapping.ENumUserType" >
>>>>> <param
>>>>> name="enumClass">org.eclipse.example.library.BookCategory</param >
>>>>> </type>
>>>>> </property>
>>>>> <many-to-one name="author" entity-name="Writer"
>>>>> cascade="merge,persist,save-update,lock,refresh" lazy="false"
>>>>> insert="false" update="false" not-null="false">
>>>>> <column not-null="false" unique="false"
>>>>> name="`book_author_e_id`"/>
>>>>> </many-to-one>
>>>>> </class>
>>>>> <class name="org.eclipse.example.library.impl.LibraryImpl"
>>>>> entity-name="Library" abstract="false" lazy="false"
>>>>> discriminator-value="Library" table="`library`">
>>>>> <meta attribute="eclassName">Library</meta>
>>>>> <meta
>>>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>>>> <id type="long" name="e_id" column="e_id"
>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>>
>>>>> <meta attribute="syntheticId">true</meta>
>>>>> <generator class="native"/>
>>>>> </id>
>>>>> <discriminator column="`dtype`" type="string"/>
>>>>> <version name="e_version" column="e_version"
>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>>>
>>>>> <meta attribute="syntheticVersion">true</meta>
>>>>> </version>
>>>>> <property name="name" lazy="false" insert="true"
>>>>> update="true" not-null="false" unique="false" type="java.lang.String">
>>>>> <column not-null="false" unique="false" name="`name`"/>
>>>>> </property>
>>>>> <list name="writers" lazy="true" cascade="all,delete-orphan">
>>>>> <key update="true">
>>>>> <column name="`library_writers_e_id`"
>>>>> not-null="false" unique="false"/>
>>>>> </key>
>>>>> <list-index column="`library_writers_idx`"/>
>>>>> <one-to-many entity-name="Writer"/>
>>>>> </list>
>>>>> <list name="books" lazy="true" cascade="all,delete-orphan">
>>>>> <key update="true">
>>>>> <column name="`library_books_e_id`"
>>>>> not-null="false" unique="false"/>
>>>>> </key>
>>>>> <list-index column="`library_books_idx`"/>
>>>>> <one-to-many entity-name="Book"/>
>>>>> </list>
>>>>> </class>
>>>>> <class name="org.eclipse.example.library.impl.WriterImpl"
>>>>> entity-name="Writer" abstract="false" lazy="false"
>>>>> discriminator-value="Writer" table="`writer`">
>>>>> <meta attribute="eclassName">Writer</meta>
>>>>> <meta
>>>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>>>> <id type="long" name="e_id" column="e_id"
>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>>
>>>>> <meta attribute="syntheticId">true</meta>
>>>>> <generator class="native"/>
>>>>> </id>
>>>>> <discriminator column="`dtype`" type="string"/>
>>>>> <version name="e_version" column="e_version"
>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>>>
>>>>> <meta attribute="syntheticVersion">true</meta>
>>>>> </version>
>>>>> <property name="name" lazy="false" insert="true"
>>>>> update="true" not-null="false" unique="false" type="java.lang.String">
>>>>> <column not-null="false" unique="false" name="`name`"/>
>>>>> </property>
>>>>> <list name="books" lazy="true"
>>>>> cascade="merge,persist,save-update,lock,refresh">
>>>>> <key update="true">
>>>>> <column name="`book_author_e_id`" not-null="false"
>>>>> unique="false"/>
>>>>> </key>
>>>>> <list-index column="`writer_books_idx`"/>
>>>>> <one-to-many entity-name="Book"/>
>>>>> </list>
>>>>> </class>
>>>>> </hibernate-mapping>
>>>>>
>>>>>
>>>>> Martin Taal wrote:
>>>>>> Alain,
>>>>>> I am a bit mistified myself also, when you set a breakpoint here:
>>>>>> BookImpl.eSet(BookImpl.java:309),
>>>>>> what is the class of the object you get and what is the class
>>>>>> instance to which the cast is tried?
>>>>>>
>>>>>> Which version of Teneo are you using?
>>>>>> Can you post/send me the hbm mapping? (you can get it by doing
>>>>>> dataStore.getMappingXML())
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Alain Picard wrote:
>>>>>>> Martin,
>>>>>>>
>>>>>>> I just made the changes and did a clean build, started with
>>>>>>> -clean, but to no avail.
>>>>>>>
>>>>>>> Any other idea?
>>>>>>>
>>>>>>> Alain
>>>>>>>
>>>>>>> Martin Taal wrote:
>>>>>>>> Hi Alain,
>>>>>>>> Can you try setting the buddy policy to dependent? Although it
>>>>>>>> is less precise (classloading can take more time) it is the
>>>>>>>> safest to try.
>>>>>>>>
>>>>>>>> gr. Martin
>>>>>>>>
>>>>>>>> Alain Picard wrote:
>>>>>>>>> I am getting acquainted with Teneo and going through the
>>>>>>>>> library editor example (after successfully doing the Tutorial1
>>>>>>>>> part). I have been able to start the wizard on an empty
>>>>>>>>> database and to create a library with a book and author.
>>>>>>>>>
>>>>>>>>> When I restart back from scratch, it attempts to load the
>>>>>>>>> content of the db and fails with the following:
>>>>>>>>> java.lang.ClassCastException:
>>>>>>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>>>>>>> org.eclipse.example.library.BookCategory
>>>>>>>>> at
>>>>>>>>> org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
>>>>>>>>> at
>>>>>>>>> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>>>>>>>>>
>>>>>>>>> at
>>>>>>>>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>>>>>>>>>
>>>>>>>>> at
>>>>>>>>> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>>>>>>>>>
>>>>>>>>> at
>>>>>>>>> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
>>>>>>>>>
>>>>>>>>> at
>>>>>>>>> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>>>>>>>>>
>>>>>>>>> .....etc
>>>>>>>>>
>>>>>>>>> This gives me the idea that I might be dealing with a
>>>>>>>>> classloader problem, since my Hibernate jars are in a different
>>>>>>>>> bundle. I have it's buddy policy set to registered and all of
>>>>>>>>> the library projects have Eclipse-RegisterBuddy: Shared_JARs
>>>>>>>>> (the bundle containing Hibernate).
>>>>>>>>>
>>>>>>>>> Does anyone has seen this before and have any clue how to fix it?
>>>>>>>>>
>>>>>>>>> Thanks
>>>>>>>>> Alain
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] ClassCastException retrieving model [message #605168 is a reply to message #81450] Mon, 30 April 2007 13:30 Go to previous message
Alain Picard is currently offline Alain PicardFriend
Messages: 235
Registered: July 2009
Senior Member
Martin,

I guess it was due to the error situation and I kept creating empty root
objects as I kept testing somehow. I cleaned them from the database and
all is well now.

I am now getting closer to doing some real world tests very soon. :)

Thanks,
Alain


Martin Taal wrote:
> Hi Alain,
> Thanks for the link, interesting article. It is a pity that java does
> not make this easier in the standard sdk.
>
> I am not sure what you do so I can not really answer the question why
> you get many empty libraries. Maybe it is related to code which
> automatically creates a root object (a library) to prevent the database
> from being empty (just guessing here).
>
> gr. Martin
>
> Alain Picard wrote:
>> Martin,
>>
>> Finally got it figured out.
>>
>> I had to hack the java.lang.ClassLoader to implement a registry
>> ( http://www.javaworld.com/javaworld/javaqa/2003-07/02-qa-0725 -classsrc2.html)
>> in order to understand what was happening. (Many other failed attempts
>> before)
>>
>> Here is what I got:
>> [org.eclipse.example.library.BookCategory]:
>> loaded by
>> [org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader(org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@1201ad7)]
>>
>> from
>> [file:/C:/eclipse/workspace/library/bin/org/eclipse/example/ library/BookCategory.class]
>>
>>
>> and then:
>> [org.eclipse.example.library.BookCategory]:
>> loaded by
>> [org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader(org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@1e7258e)]
>>
>> from
>> [jar:file:/C:/eclipse/products/emft-teneo-ex-7423/eclipse/pl ugins/org.eclipse.emf.teneo.tutorial_0.8.0.v200704230019.jar !/org/eclipse/example/library/BookCategory.class]
>>
>>
>>
>> Guess I had the example jar installed and getting in the way from my
>> original library project and that was also the reason i could only see
>> 1 call to the static block in BookCategory.
>>
>> Now I need to understand why I am getting a large number of empty "My
>> Library" under the single truly populated one.
>>
>> Do you have any clue?
>>
>> Thanks
>> Alain
>>
>>
>>
>> Martin Taal wrote:
>>> Hi Alain,
>>> Hmm where do you initialise the datastore (in which plugin)?
>>>
>>> Teneo can be set to use another classloader you can do this by
>>> calling the method:
>>> ClassLoaderResolver.setClassLoaderStrategy(ClassLoaderStrate gy
>>> classLoaderStrategy)
>>> with your own ClassLoaderStrategy before initializing the datastore.
>>>
>>> The ClassLoaderStrategy is a simple interface which returns the
>>> classloader which you want to use.
>>>
>>> As a default Teneo uses the ContextClassLoaderStrategy but there is
>>> also the ClassClassLoaderStrategy which uses the classloader of the
>>> calling class.
>>>
>>> gr. Martin
>>>
>>> Alain Picard wrote:
>>>> Martin,
>>>>
>>>> Here is what I am getting (in order):
>>>> In static init of BookCategory.
>>>> CL:org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea
>>>>
>>>> In ENumUserType with enumClassName of:
>>>> org.eclipse.example.library.BookCategory
>>>>
>>>> then it goes to get the classForName:
>>>> Thread.getContextClassLoader() line: 1314 [local variables
>>>> unavailable] ContextClassLoaderStrategy.getClassLoader() line:
>>>> 32 ClassLoaderResolver.getClassLoader() line: 59
>>>> ClassLoaderResolver.classForName(String) line: 51
>>>> ENumUserType.setParameterValues(Properties) line: 175 with
>>>> Thread.getContextClassLoader() returning the following
>>>> contextClassLoader:
>>>> org.eclipse.core.runtime.internal.adaptor.ContextFinder@d82aff
>>>> with parent: sun.misc.Launcher$AppClassLoader@1a7bf11
>>>> with parent: sun.misc.Launcher$ExtClassLoader@1f12c4e
>>>> with parent: null
>>>>
>>>> Then later in BookImpl eSet i get the following (where the CL
>>>> matched the one reported in the static constructor):
>>>> BookCaterogy CL:
>>>> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@90d0ea
>>>> parent:
>>>> org.eclipse.osgi.baseadaptor.BaseAdaptor$ParentClassLoader@16917ee
>>>> parent: null
>>>>
>>>> The message in the BookCategory static constructor is only called
>>>> once at the beginning of this trace.
>>>>
>>>> Also when you mentioned:
>>>> > In the debugger you can try to walk through the
>>>> > classloader hierarchy to see if the two classloaders are related.
>>>> Is there any way to walk the complete classloader hierarchy starting
>>>> from the root. What I am getting doesn't even agree on a root.
>>>>
>>>> Thanks
>>>> Alain
>>>>
>>>>
>>>> Martin Taal wrote:
>>>>> Alain,
>>>>> I am not sure why this does not work but I can give you some more
>>>>> background information for you to look at. At your breakpoint in
>>>>> the BookImpl.eSet you can get the classloader from both the
>>>>> BookCategory class used for the cast as well as the classloader
>>>>> (getClassLoader() method on the class itself). The same can be done
>>>>> for the class of the passed object. In the debugger you can try to
>>>>> walk through the classloader hierarchy to see if the two
>>>>> classloaders are related.
>>>>>
>>>>> The (BookCategory) class of the passed object in the eSet is loaded
>>>>> in the EnumUserType class in the setParameterValues method. This is
>>>>> done when you initialize the datastore. As a default teneo uses the
>>>>> ContextClassLoaderStrategy (see org.eclipse.emf.teneo.classloader)
>>>>> which uses the following to load the class:
>>>>> Thread.currentThread().getContextClassLoader()
>>>>>
>>>>> I do not know how/when the second classloader (which reads its own
>>>>> BookCategory) comes into play. To analyse this it could help to put
>>>>> a static initializer block in the BookCategory class with a
>>>>> breakpoint (or print the stack trace) and then see when this is
>>>>> executed (twice).
>>>>>
>>>>> It seems that the initialization of the datastore uses a
>>>>> classloader which is not related to the classloader which later
>>>>> reads the library model again for your plugins.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Alain Picard wrote:
>>>>>> Martin,
>>>>>>
>>>>>> I get a org.eclipse.example.library.BookCategory and it is being
>>>>>> cast to BookCategory as the error mentioned:
>>>>>> java.lang.ClassCastException:
>>>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>>>> org.eclipse.example.library.BookCategory
>>>>>>
>>>>>> I am using the latest version of Teneo (0.8
>>>>>> emft-teneo-SDK-I200704230019) with EMF (emf-sdo-xsd-SDK-2.3.0M6)
>>>>>> under Eclipse 3.3M6
>>>>>>
>>>>>> I am trying to get some trace info to get the class loader tree,
>>>>>> but I am still fighting that battle.
>>>>>>
>>>>>> Thanks for your help.
>>>>>> Alain
>>>>>>
>>>>>>
>>>>>> Here is the mapping info:
>>>>>> <hibernate-mapping>
>>>>>> <class name="org.eclipse.example.library.impl.BookImpl"
>>>>>> entity-name="Book" abstract="false" lazy="false"
>>>>>> discriminator-value="Book" table="`book`">
>>>>>> <meta attribute="eclassName">Book</meta>
>>>>>> <meta
>>>>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>>>>> <id type="long" name="e_id" column="e_id"
>>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>>>
>>>>>> <meta attribute="syntheticId">true</meta>
>>>>>> <generator class="native"/>
>>>>>> </id>
>>>>>> <discriminator column="`dtype`" type="string"/>
>>>>>> <version name="e_version" column="e_version"
>>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>>>>
>>>>>> <meta attribute="syntheticVersion">true</meta>
>>>>>> </version>
>>>>>> <property name="title" lazy="false" insert="true"
>>>>>> update="true" not-null="false" unique="false"
>>>>>> type="java.lang.String">
>>>>>> <column not-null="false" unique="false" name="`title`"/>
>>>>>> </property>
>>>>>> <property name="pages" lazy="false" insert="true"
>>>>>> update="true" not-null="false" unique="false" type="int">
>>>>>> <column not-null="false" unique="false" name="`pages`"/>
>>>>>> </property>
>>>>>> <property name="category" lazy="false" not-null="false"
>>>>>> insert="true" update="true" unique="false">
>>>>>> <column not-null="false" unique="false"
>>>>>> name="`category`"/>
>>>>>> <type
>>>>>> name="org.eclipse.emf.teneo.hibernate.mapping.ENumUserType" >
>>>>>> <param
>>>>>> name="enumClass">org.eclipse.example.library.BookCategory</param >
>>>>>> </type>
>>>>>> </property>
>>>>>> <many-to-one name="author" entity-name="Writer"
>>>>>> cascade="merge,persist,save-update,lock,refresh" lazy="false"
>>>>>> insert="false" update="false" not-null="false">
>>>>>> <column not-null="false" unique="false"
>>>>>> name="`book_author_e_id`"/>
>>>>>> </many-to-one>
>>>>>> </class>
>>>>>> <class name="org.eclipse.example.library.impl.LibraryImpl"
>>>>>> entity-name="Library" abstract="false" lazy="false"
>>>>>> discriminator-value="Library" table="`library`">
>>>>>> <meta attribute="eclassName">Library</meta>
>>>>>> <meta
>>>>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>>>>> <id type="long" name="e_id" column="e_id"
>>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>>>
>>>>>> <meta attribute="syntheticId">true</meta>
>>>>>> <generator class="native"/>
>>>>>> </id>
>>>>>> <discriminator column="`dtype`" type="string"/>
>>>>>> <version name="e_version" column="e_version"
>>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>>>>
>>>>>> <meta attribute="syntheticVersion">true</meta>
>>>>>> </version>
>>>>>> <property name="name" lazy="false" insert="true"
>>>>>> update="true" not-null="false" unique="false"
>>>>>> type="java.lang.String">
>>>>>> <column not-null="false" unique="false" name="`name`"/>
>>>>>> </property>
>>>>>> <list name="writers" lazy="true" cascade="all,delete-orphan">
>>>>>> <key update="true">
>>>>>> <column name="`library_writers_e_id`"
>>>>>> not-null="false" unique="false"/>
>>>>>> </key>
>>>>>> <list-index column="`library_writers_idx`"/>
>>>>>> <one-to-many entity-name="Writer"/>
>>>>>> </list>
>>>>>> <list name="books" lazy="true" cascade="all,delete-orphan">
>>>>>> <key update="true">
>>>>>> <column name="`library_books_e_id`"
>>>>>> not-null="false" unique="false"/>
>>>>>> </key>
>>>>>> <list-index column="`library_books_idx`"/>
>>>>>> <one-to-many entity-name="Book"/>
>>>>>> </list>
>>>>>> </class>
>>>>>> <class name="org.eclipse.example.library.impl.WriterImpl"
>>>>>> entity-name="Writer" abstract="false" lazy="false"
>>>>>> discriminator-value="Writer" table="`writer`">
>>>>>> <meta attribute="eclassName">Writer</meta>
>>>>>> <meta
>>>>>> attribute="epackage">http:///org/eclipse/example/library.ecore</meta>
>>>>>> <id type="long" name="e_id" column="e_id"
>>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>>>
>>>>>> <meta attribute="syntheticId">true</meta>
>>>>>> <generator class="native"/>
>>>>>> </id>
>>>>>> <discriminator column="`dtype`" type="string"/>
>>>>>> <version name="e_version" column="e_version"
>>>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
>>>>>>
>>>>>> <meta attribute="syntheticVersion">true</meta>
>>>>>> </version>
>>>>>> <property name="name" lazy="false" insert="true"
>>>>>> update="true" not-null="false" unique="false"
>>>>>> type="java.lang.String">
>>>>>> <column not-null="false" unique="false" name="`name`"/>
>>>>>> </property>
>>>>>> <list name="books" lazy="true"
>>>>>> cascade="merge,persist,save-update,lock,refresh">
>>>>>> <key update="true">
>>>>>> <column name="`book_author_e_id`" not-null="false"
>>>>>> unique="false"/>
>>>>>> </key>
>>>>>> <list-index column="`writer_books_idx`"/>
>>>>>> <one-to-many entity-name="Book"/>
>>>>>> </list>
>>>>>> </class>
>>>>>> </hibernate-mapping>
>>>>>>
>>>>>>
>>>>>> Martin Taal wrote:
>>>>>>> Alain,
>>>>>>> I am a bit mistified myself also, when you set a breakpoint here:
>>>>>>> BookImpl.eSet(BookImpl.java:309),
>>>>>>> what is the class of the object you get and what is the class
>>>>>>> instance to which the cast is tried?
>>>>>>>
>>>>>>> Which version of Teneo are you using?
>>>>>>> Can you post/send me the hbm mapping? (you can get it by doing
>>>>>>> dataStore.getMappingXML())
>>>>>>>
>>>>>>> gr. Martin
>>>>>>>
>>>>>>> Alain Picard wrote:
>>>>>>>> Martin,
>>>>>>>>
>>>>>>>> I just made the changes and did a clean build, started with
>>>>>>>> -clean, but to no avail.
>>>>>>>>
>>>>>>>> Any other idea?
>>>>>>>>
>>>>>>>> Alain
>>>>>>>>
>>>>>>>> Martin Taal wrote:
>>>>>>>>> Hi Alain,
>>>>>>>>> Can you try setting the buddy policy to dependent? Although it
>>>>>>>>> is less precise (classloading can take more time) it is the
>>>>>>>>> safest to try.
>>>>>>>>>
>>>>>>>>> gr. Martin
>>>>>>>>>
>>>>>>>>> Alain Picard wrote:
>>>>>>>>>> I am getting acquainted with Teneo and going through the
>>>>>>>>>> library editor example (after successfully doing the Tutorial1
>>>>>>>>>> part). I have been able to start the wizard on an empty
>>>>>>>>>> database and to create a library with a book and author.
>>>>>>>>>>
>>>>>>>>>> When I restart back from scratch, it attempts to load the
>>>>>>>>>> content of the db and fails with the following:
>>>>>>>>>> java.lang.ClassCastException:
>>>>>>>>>> org.eclipse.example.library.BookCategory cannot be cast to
>>>>>>>>>> org.eclipse.example.library.BookCategory
>>>>>>>>>> at
>>>>>>>>>> org.eclipse.example.library.impl.BookImpl.eSet(BookImpl.java :309)
>>>>>>>>>> at
>>>>>>>>>> org.eclipse.emf.teneo.hibernate.mapping.property.EAttributeP ropertyHandler.set(EAttributePropertyHandler.java:191)
>>>>>>>>>>
>>>>>>>>>> at
>>>>>>>>>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:337)
>>>>>>>>>>
>>>>>>>>>> at
>>>>>>>>>> org.hibernate.persister.entity.AbstractEntityPersister.setPr opertyValues(AbstractEntityPersister.java:3564)
>>>>>>>>>>
>>>>>>>>>> at
>>>>>>>>>> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseL oad.java:129)
>>>>>>>>>>
>>>>>>>>>> at
>>>>>>>>>> org.hibernate.loader.Loader.initializeEntitiesAndCollections (Loader.java:854)
>>>>>>>>>>
>>>>>>>>>> .....etc
>>>>>>>>>>
>>>>>>>>>> This gives me the idea that I might be dealing with a
>>>>>>>>>> classloader problem, since my Hibernate jars are in a
>>>>>>>>>> different bundle. I have it's buddy policy set to registered
>>>>>>>>>> and all of the library projects have Eclipse-RegisterBuddy:
>>>>>>>>>> Shared_JARs (the bundle containing Hibernate).
>>>>>>>>>>
>>>>>>>>>> Does anyone has seen this before and have any clue how to fix it?
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>> Alain
>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Previous Topic:[Teneo] GMF Editors
Next Topic:[Teneo+hibernate]
Goto Forum:
  


Current Time: Mon Jan 25 14:52:45 GMT 2021

Powered by FUDForum. Page generated in 0.02628 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top