Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » ClassCastException to EList
ClassCastException to EList [message #122721] Tue, 20 May 2008 21:06 Go to next message
Eclipse UserFriend
Originally posted by: insanitydesign.yahoo.de

Hello,

I am currently conducting some research on how to maybe change the
software development workflow and structure in my institute. As I do
not like too suffocating solutions I thought about some modelling
approach through EMF, Teneo and DataNucleus.

So I got myself everything needed, read all guides I could find on
eclipse.org, elver.org and datanucleus.org and started with a basic
model with basic relations. Everything worked so far as that I could
- build the model (the example model from this site http://www.eclipse.org/gmt/oaw/doc/4.2/html/contents/emf_tut orial.html),
- create the genmodel,
- generated the code and even the
- package.jdo.
Everything got enhanced and then I thought I could start persisting
everything... so I thought. All the time I get the error:
java.lang.ClassCastException: org.datanucleus.sco.List cannot be cast
to org.eclipse.emf.common.util.EList

I looked it up, searched the newslists and forums but I couldn't figure
out the solution. I know that there is probably an error about the
implementing SCO for EList and DataNucleus, but I cannot figure out
how to tell him what to use. I found tutorials about extensions and
tried that but maybe I am just to slow for that. I do not really get the
TypeMapping.

The code is plain simple I think:

PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("datanucleus.properties ");
PersistenceManager pm = pmf.getPersistenceManager();

Transaction tx = pm.currentTransaction();
try {
tx.begin();

//
DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
datamodel.setName("DataModel");

//
pm.makePersistent(datamodel);

tx.commit();

} finally {
if(tx.isActive()) {
tx.rollback();
}
pm.close();
}

The tables are created in the database (a test MySQL DB). But
pm.makePersistent(datamodel); kicks him out with the exception.

I tried the creation with

JpoxDataStore jpoxDataStore = JpoxHelper.INSTANCE.createRegisterDataStore("Data");

but that throws errors from the beginning, as I think maybe something
changed from Jpox to DataNucleus. So I tried older versions, before
DataNucleus, so with Jpox directly, then the jpoxDataStore.initialize();
keeps getting errors.

As you can see I am very desperate at the moment and I hope anyone can help me.

Many many thanks in advance and thanks for every response.


Regards
Ziplies


PS: I am using Eclipse 3.4M7 (but I have different installations
with different plugins running, for testing purposes),
EMF 2.4.0v200805052017 and Teneo 0.8.0v200804231747 with DataNucleus 1.0.0m1.

The ecore model is following, the rest is generated through the described plugins
plus my Test Class up above:

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="data"
nsURI="http://www.openarchitectureware.org/oaw4.demo.emf.datamodel" nsPrefix="data">
<eClassifiers xsi:type="ecore:EClass" name="DataModel">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="entity" upperBound="-1"
eType="#//Entity" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Entity">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="attribute" lowerBound="1"
upperBound="-1" eType="#//Attribute" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="reference" upperBound="-1"
eType="#//EntityReference" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Attribute">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="EntityReference">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="toMany" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="target" lowerBound="1"
eType="#//Entity"/>
</eClassifiers>
</ecore:EPackage>
Re: ClassCastException to EList [message #122726 is a reply to message #122721] Tue, 20 May 2008 21:17 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Ziplies,
Have you tried with jpox 1.1.9? That is the version currently working with Teneo. It is clearly on
my roadmap to upgrade to newer versions of jpox/datanucleus. I have not yet had time to do so.

If you get exceptions/errors can you post the stacktrace? That always gives some more info.

gr. Martin

Savas Ziplies wrote:
> Hello,
>
> I am currently conducting some research on how to maybe change the
> software development workflow and structure in my institute. As I do
> not like too suffocating solutions I thought about some modelling
> approach through EMF, Teneo and DataNucleus.
>
> So I got myself everything needed, read all guides I could find on
> eclipse.org, elver.org and datanucleus.org and started with a basic
> model with basic relations. Everything worked so far as that I could
> - build the model (the example model from this site
> http://www.eclipse.org/gmt/oaw/doc/4.2/html/contents/emf_tut orial.html),
> - create the genmodel, - generated the code and even the
> - package.jdo. Everything got enhanced and then I thought I could start
> persisting everything... so I thought. All the time I get the error:
> java.lang.ClassCastException: org.datanucleus.sco.List cannot be cast
> to org.eclipse.emf.common.util.EList
>
> I looked it up, searched the newslists and forums but I couldn't figure
> out the solution. I know that there is probably an error about the
> implementing SCO for EList and DataNucleus, but I cannot figure out
> how to tell him what to use. I found tutorials about extensions and
> tried that but maybe I am just to slow for that. I do not really get the
> TypeMapping.
>
> The code is plain simple I think:
>
> PersistenceManagerFactory pmf =
> JDOHelper.getPersistenceManagerFactory("datanucleus.properties ");
> PersistenceManager pm = pmf.getPersistenceManager();
>
> Transaction tx = pm.currentTransaction();
> try {
> tx.begin();
>
> //
> DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
> datamodel.setName("DataModel");
>
> //
> pm.makePersistent(datamodel);
>
> tx.commit();
>
> } finally {
> if(tx.isActive()) {
> tx.rollback();
> }
> pm.close();
> }
>
> The tables are created in the database (a test MySQL DB). But
> pm.makePersistent(datamodel); kicks him out with the exception.
>
> I tried the creation with
>
> JpoxDataStore jpoxDataStore =
> JpoxHelper.INSTANCE.createRegisterDataStore("Data");
>
> but that throws errors from the beginning, as I think maybe something
> changed from Jpox to DataNucleus. So I tried older versions, before
> DataNucleus, so with Jpox directly, then the jpoxDataStore.initialize();
> keeps getting errors.
>
> As you can see I am very desperate at the moment and I hope anyone can
> help me.
>
> Many many thanks in advance and thanks for every response.
>
>
> Regards
> Ziplies
>
>
> PS: I am using Eclipse 3.4M7 (but I have different installations
> with different plugins running, for testing purposes), EMF
> 2.4.0v200805052017 and Teneo 0.8.0v200804231747 with DataNucleus 1.0.0m1.
>
> The ecore model is following, the rest is generated through the
> described plugins
> plus my Test Class up above:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="data"
> nsURI="http://www.openarchitectureware.org/oaw4.demo.emf.datamodel"
> nsPrefix="data">
> <eClassifiers xsi:type="ecore:EClass" name="DataModel">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="entity"
> upperBound="-1"
> eType="#//Entity" containment="true"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Entity">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="attribute"
> lowerBound="1"
> upperBound="-1" eType="#//Attribute" containment="true"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="reference"
> upperBound="-1"
> eType="#//EntityReference" containment="true"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Attribute">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="EntityReference">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="toMany"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="target"
> lowerBound="1"
> eType="#//Entity"/>
> </eClassifiers>
> </ecore:EPackage>


--

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: ClassCastException to EList [message #122784 is a reply to message #122726] Wed, 21 May 2008 16:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: insanitydesign.yahoo.de

Hi,

so after I always tested with Jpox1.2.2 or DataNucleus1.0.0m1 I got it to work with Jpox1.1.9, like you proposed. First of all thanks for that!
Now I got Eclipse3.3.2 running with EMF2.3.2, Teneo I0.8.0 and Jpox1.1.9.

But, I was eager to know why since Jpox1.2.0 it is not running anymore, because from Version 1.2 beginning I get different errors, and maybe you can help to fix them or can use them as BugReports.

So, the same configuration (Eclipse3.3.2 running with EMF2.3.2, Teneo I0.8.0) with Jpox1.2.0 gives me two differnt errors on different approaches.
First:
If I try to initialize in 1.2.0 with
//
Properties properties = new Properties();
properties.setProperty("javax.jdo.option.ConnectionDriverName ", "com.mysql.jdbc.Driver");
properties.setProperty("javax.jdo.option.ConnectionURL", "jdbc:mysql://127.0.0.1:3306/emf_jpox122");
properties.setProperty("javax.jdo.option.ConnectionUserName ", "root");
properties.setProperty("javax.jdo.option.ConnectionPassword ", "vertrigo");

//
String pmfName = "emf"; // the name of the JpoxDataStore
JpoxDataStore jpoxDataStore = JpoxHelper.INSTANCE.createRegisterDataStore(pmfName);
jpoxDataStore.setProperties(properties);
jpoxDataStore.setEPackages(new EPackage[]{DataPackage.eINSTANCE});
jpoxDataStore.initialize();

the line jpoxDataStore.initialize(); is throwing the following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/jpox/AbstractPersistenceManagerFactory
at org.eclipse.emf.teneo.jpox.JpoxDataStore.createSchema(JpoxDa taStore.java:536)
at org.eclipse.emf.teneo.jpox.JpoxDataStore.initialize(JpoxData Store.java:228)
at Run.<init>(Run.java:64)
at Run.main(Run.java:30)
Caused by: java.lang.ClassNotFoundException: org.jpox.AbstractPersistenceManagerFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 4 more

So I tried to initialize everything by the lines:
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("jpox.properties");
PersistenceManager pm = pmf.getPersistenceManager();

with the jpox.properties:
javax.jdo.PersistenceManagerFactoryClass=org.jpox.jdo.JDOPer sistenceManagerFactory
javax.jdo.option.ConnectionDriverName=com.mysql.jdbc.Driver
javax.jdo.option.ConnectionURL=jdbc:mysql://127.0.0.1/emf_jpox122
javax.jdo.option.ConnectionUserName=root
javax.jdo.option.ConnectionPassword=vertrigo
org.jpox.autoCreateTables=true
org.jpox.autoCreateSchema=true
org.jpox.validateTables=false
org.jpox.validateConstraints=false

and it starts and even creates all tables, but as soon as I create an object and try to persist it with:
Transaction tx = pm.currentTransaction();
try {
tx.begin();

//Create Entity
Entity entity = DataFactory.eINSTANCE.createEntity();
entity.setName("Entity");

//Create DataModel
DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
datamodel.setName("DataModel");
datamodel.getEntity().add(entity);

//
pm.makePersistent(datamodel);

tx.commit();

} finally {
if(tx.isActive()) {
tx.rollback();
}
pm.close();
}

pm.makePersistent(datamodel); throws the following exception:
java.lang.ClassCastException: org.jpox.sco.List cannot be cast to org.eclipse.emf.common.util.EList
at data.impl.EntityImpl.jdoReplaceField(EntityImpl.java)
at org.jpox.state.JDOStateManagerImpl.replaceField(JDOStateMana gerImpl.java:2546)
at org.jpox.state.JDOStateManagerImpl.replaceField(JDOStateMana gerImpl.java:2425)
at org.jpox.sco.SCOUtils.newSCOInstance(SCOUtils.java:173)
at org.jpox.store.mapped.mapping.AbstractContainerMapping.repla ceFieldWithWrapper(AbstractContainerMapping.java:394)
at org.jpox.store.mapped.mapping.CollectionMapping.postInsert(C ollectionMapping.java:103)
at org.jpox.store.rdbms.request.InsertRequest.execute(InsertReq uest.java:465)
at org.jpox.store.rdbms.RDBMSPersistenceHandler.insertTable(RDB MSPersistenceHandler.java:157)
at org.jpox.store.rdbms.RDBMSPersistenceHandler.insertObject(RD BMSPersistenceHandler.java:136)
at org.jpox.state.JDOStateManagerImpl.internalMakePersistent(JD OStateManagerImpl.java:3082)
at org.jpox.state.JDOStateManagerImpl.makePersistent(JDOStateMa nagerImpl.java:3062)
at org.jpox.ObjectManagerImpl.persistObjectInternal(ObjectManag erImpl.java:1231)
at org.jpox.sco.SCOUtils.validateObjectForWriting(SCOUtils.java :1491)
at org.jpox.store.rdbms.scostore.ElementContainerStore.validate ElementForWriting(ElementContainerStore.java:379)
at org.jpox.store.rdbms.scostore.FKListStore.validateElementFor Writing(FKListStore.java:1303)
at org.jpox.store.rdbms.scostore.FKListStore.internalAdd(FKList Store.java:830)
at org.jpox.store.rdbms.scostore.AbstractListStore.addAll(Abstr actListStore.java:354)
at org.jpox.store.mapped.mapping.CollectionMapping.postInsert(C ollectionMapping.java:158)
at org.jpox.store.rdbms.request.InsertRequest.execute(InsertReq uest.java:465)
at org.jpox.store.rdbms.RDBMSPersistenceHandler.insertTable(RDB MSPersistenceHandler.java:157)
at org.jpox.store.rdbms.RDBMSPersistenceHandler.insertObject(RD BMSPersistenceHandler.java:136)
at org.jpox.state.JDOStateManagerImpl.internalMakePersistent(JD OStateManagerImpl.java:3082)
at org.jpox.state.JDOStateManagerImpl.makePersistent(JDOStateMa nagerImpl.java:3062)
at org.jpox.ObjectManagerImpl.persistObjectInternal(ObjectManag erImpl.java:1231)
at org.jpox.ObjectManagerImpl.persistObject(ObjectManagerImpl.j ava:1077)
at org.jpox.jdo.AbstractPersistenceManager.jdoMakePersistent(Ab stractPersistenceManager.java:666)
at org.jpox.jdo.AbstractPersistenceManager.makePersistent(Abstr actPersistenceManager.java:691)

So again the casting error.

I hope anyone can help me with that or does know what needs to be done. Again, thanks in advance.


Regards
Ziplies


Martin Taal wrote:
> Hi Ziplies,
> Have you tried with jpox 1.1.9? That is the version currently working
> with Teneo. It is clearly on my roadmap to upgrade to newer versions of
> jpox/datanucleus. I have not yet had time to do so.
>
> If you get exceptions/errors can you post the stacktrace? That always
> gives some more info.
>
> gr. Martin
>
> Savas Ziplies wrote:
>> Hello,
>>
>> I am currently conducting some research on how to maybe change the
>> software development workflow and structure in my institute. As I do
>> not like too suffocating solutions I thought about some modelling
>> approach through EMF, Teneo and DataNucleus.
>>
>> So I got myself everything needed, read all guides I could find on
>> eclipse.org, elver.org and datanucleus.org and started with a basic
>> model with basic relations. Everything worked so far as that I could
>> - build the model (the example model from this site
>> http://www.eclipse.org/gmt/oaw/doc/4.2/html/contents/emf_tut orial.html),
>> - create the genmodel, - generated the code and even the
>> - package.jdo. Everything got enhanced and then I thought I could
>> start persisting everything... so I thought. All the time I get the
>> error:
>> java.lang.ClassCastException: org.datanucleus.sco.List cannot be cast
>> to org.eclipse.emf.common.util.EList
>>
>> I looked it up, searched the newslists and forums but I couldn't figure
>> out the solution. I know that there is probably an error about the
>> implementing SCO for EList and DataNucleus, but I cannot figure out
>> how to tell him what to use. I found tutorials about extensions and
>> tried that but maybe I am just to slow for that. I do not really get the
>> TypeMapping.
>>
>> The code is plain simple I think:
>>
>> PersistenceManagerFactory pmf =
>> JDOHelper.getPersistenceManagerFactory("datanucleus.properties ");
>> PersistenceManager pm = pmf.getPersistenceManager();
>>
>> Transaction tx = pm.currentTransaction();
>> try {
>> tx.begin();
>>
>> //
>> DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
>> datamodel.setName("DataModel");
>>
>> //
>> pm.makePersistent(datamodel);
>>
>> tx.commit();
>>
>> } finally {
>> if(tx.isActive()) {
>> tx.rollback();
>> }
>> pm.close();
>> }
>>
>> The tables are created in the database (a test MySQL DB). But
>> pm.makePersistent(datamodel); kicks him out with the exception.
>>
>> I tried the creation with
>>
>> JpoxDataStore jpoxDataStore =
>> JpoxHelper.INSTANCE.createRegisterDataStore("Data");
>>
>> but that throws errors from the beginning, as I think maybe something
>> changed from Jpox to DataNucleus. So I tried older versions, before
>> DataNucleus, so with Jpox directly, then the
>> jpoxDataStore.initialize(); keeps getting errors.
>>
>> As you can see I am very desperate at the moment and I hope anyone can
>> help me.
>>
>> Many many thanks in advance and thanks for every response.
>>
>>
>> Regards
>> Ziplies
>>
>>
>> PS: I am using Eclipse 3.4M7 (but I have different installations
>> with different plugins running, for testing purposes), EMF
>> 2.4.0v200805052017 and Teneo 0.8.0v200804231747 with DataNucleus 1.0.0m1.
>>
>> The ecore model is following, the rest is generated through the
>> described plugins
>> plus my Test Class up above:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <ecore:EPackage xmi:version="2.0"
>> xmlns:xmi="http://www.omg.org/XMI"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="data"
>> nsURI="http://www.openarchitectureware.org/oaw4.demo.emf.datamodel"
>> nsPrefix="data">
>> <eClassifiers xsi:type="ecore:EClass" name="DataModel">
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="entity"
>> upperBound="-1"
>> eType="#//Entity" containment="true"/>
>> </eClassifiers>
>> <eClassifiers xsi:type="ecore:EClass" name="Entity">
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="attribute"
>> lowerBound="1"
>> upperBound="-1" eType="#//Attribute" containment="true"/>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="reference"
>> upperBound="-1"
>> eType="#//EntityReference" containment="true"/>
>> </eClassifiers>
>> <eClassifiers xsi:type="ecore:EClass" name="Attribute">
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>> </eClassifiers>
>> <eClassifiers xsi:type="ecore:EClass" name="EntityReference">
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="toMany"
>> eType="ecore:EDataType
>> http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="target"
>> lowerBound="1"
>> eType="#//Entity"/>
>> </eClassifiers>
>> </ecore:EPackage>
>
>
Re: ClassCastException to EList [message #122790 is a reply to message #122784] Wed, 21 May 2008 16:54 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Ziplies,
Jpox has made a lot of internal api changes going from 1.1.9 to 1.2. I have not yet had the time to
upgrade Teneo to jpox 1.2 (as Teneo uses the internal jpox api). This is a fair amount of work which
I need to look at in more detail. Also I was a bit reluctant because going to jpox 1.2 means that
all current jpox-teneo users also needed to upgrade to 1.2. I don't have the capacity to maintain
multiple Teneo branches for different versions of jpox.
Teneo-Jpox has about 85 testcases which are run in 2 scenarios. If I run these testcases on jpox 1.2
then about half will fail. So before it makes sense for you to test it I would first need to get all
the testcases to pass...

The only thing you can do at the moment is be patient and add your name to the bugzilla for this to
get an update on what happens:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=195434

gr. Martin

Savas Ziplies wrote:
> Hi,
>
> so after I always tested with Jpox1.2.2 or DataNucleus1.0.0m1 I got it
> to work with Jpox1.1.9, like you proposed. First of all thanks for that!
> Now I got Eclipse3.3.2 running with EMF2.3.2, Teneo I0.8.0 and Jpox1.1.9.
> But, I was eager to know why since Jpox1.2.0 it is not running anymore,
> because from Version 1.2 beginning I get different errors, and maybe you
> can help to fix them or can use them as BugReports.
>
> So, the same configuration (Eclipse3.3.2 running with EMF2.3.2, Teneo
> I0.8.0) with Jpox1.2.0 gives me two differnt errors on different
> approaches. First:
> If I try to initialize in 1.2.0 with
> //
> Properties properties = new Properties();
> properties.setProperty("javax.jdo.option.ConnectionDriverName ",
> "com.mysql.jdbc.Driver");
> properties.setProperty("javax.jdo.option.ConnectionURL",
> "jdbc:mysql://127.0.0.1:3306/emf_jpox122");
> properties.setProperty("javax.jdo.option.ConnectionUserName ", "root");
> properties.setProperty("javax.jdo.option.ConnectionPassword ", "vertrigo");
>
> //
> String pmfName = "emf"; // the name of the JpoxDataStore
> JpoxDataStore jpoxDataStore =
> JpoxHelper.INSTANCE.createRegisterDataStore(pmfName);
> jpoxDataStore.setProperties(properties);
> jpoxDataStore.setEPackages(new EPackage[]{DataPackage.eINSTANCE});
> jpoxDataStore.initialize();
>
> the line jpoxDataStore.initialize(); is throwing the following exception:
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/jpox/AbstractPersistenceManagerFactory
> at
> org.eclipse.emf.teneo.jpox.JpoxDataStore.createSchema(JpoxDa taStore.java:536)
>
> at
> org.eclipse.emf.teneo.jpox.JpoxDataStore.initialize(JpoxData Store.java:228)
> at Run.<init>(Run.java:64)
> at Run.main(Run.java:30)
> Caused by: java.lang.ClassNotFoundException:
> org.jpox.AbstractPersistenceManagerFactory
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
> ... 4 more
>
> So I tried to initialize everything by the lines:
> PersistenceManagerFactory pmf =
> JDOHelper.getPersistenceManagerFactory("jpox.properties");
> PersistenceManager pm = pmf.getPersistenceManager();
>
> with the jpox.properties:
> javax.jdo.PersistenceManagerFactoryClass=org.jpox.jdo.JDOPer sistenceManagerFactory
>
> javax.jdo.option.ConnectionDriverName=com.mysql.jdbc.Driver
> javax.jdo.option.ConnectionURL=jdbc:mysql://127.0.0.1/emf_jpox122
> javax.jdo.option.ConnectionUserName=root
> javax.jdo.option.ConnectionPassword=vertrigo
> org.jpox.autoCreateTables=true
> org.jpox.autoCreateSchema=true
> org.jpox.validateTables=false
> org.jpox.validateConstraints=false
>
> and it starts and even creates all tables, but as soon as I create an
> object and try to persist it with:
> Transaction tx = pm.currentTransaction();
> try {
> tx.begin();
>
> //Create Entity
> Entity entity = DataFactory.eINSTANCE.createEntity();
> entity.setName("Entity");
>
> //Create DataModel
> DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
> datamodel.setName("DataModel");
> datamodel.getEntity().add(entity);
> //
> pm.makePersistent(datamodel);
>
> tx.commit();
>
> } finally {
> if(tx.isActive()) {
> tx.rollback();
> }
> pm.close();
> }
>
> pm.makePersistent(datamodel); throws the following exception:
> java.lang.ClassCastException: org.jpox.sco.List cannot be cast to
> org.eclipse.emf.common.util.EList
> at data.impl.EntityImpl.jdoReplaceField(EntityImpl.java)
> at
> org.jpox.state.JDOStateManagerImpl.replaceField(JDOStateMana gerImpl.java:2546)
>
> at
> org.jpox.state.JDOStateManagerImpl.replaceField(JDOStateMana gerImpl.java:2425)
>
> at org.jpox.sco.SCOUtils.newSCOInstance(SCOUtils.java:173)
> at
> org.jpox.store.mapped.mapping.AbstractContainerMapping.repla ceFieldWithWrapper(AbstractContainerMapping.java:394)
>
> at
> org.jpox.store.mapped.mapping.CollectionMapping.postInsert(C ollectionMapping.java:103)
>
> at
> org.jpox.store.rdbms.request.InsertRequest.execute(InsertReq uest.java:465)
> at
> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertTable(RDB MSPersistenceHandler.java:157)
>
> at
> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertObject(RD BMSPersistenceHandler.java:136)
>
> at
> org.jpox.state.JDOStateManagerImpl.internalMakePersistent(JD OStateManagerImpl.java:3082)
>
> at
> org.jpox.state.JDOStateManagerImpl.makePersistent(JDOStateMa nagerImpl.java:3062)
>
> at
> org.jpox.ObjectManagerImpl.persistObjectInternal(ObjectManag erImpl.java:1231)
>
> at org.jpox.sco.SCOUtils.validateObjectForWriting(SCOUtils.java :1491)
> at
> org.jpox.store.rdbms.scostore.ElementContainerStore.validate ElementForWriting(ElementContainerStore.java:379)
>
> at
> org.jpox.store.rdbms.scostore.FKListStore.validateElementFor Writing(FKListStore.java:1303)
>
> at
> org.jpox.store.rdbms.scostore.FKListStore.internalAdd(FKList Store.java:830)
> at
> org.jpox.store.rdbms.scostore.AbstractListStore.addAll(Abstr actListStore.java:354)
>
> at
> org.jpox.store.mapped.mapping.CollectionMapping.postInsert(C ollectionMapping.java:158)
>
> at
> org.jpox.store.rdbms.request.InsertRequest.execute(InsertReq uest.java:465)
> at
> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertTable(RDB MSPersistenceHandler.java:157)
>
> at
> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertObject(RD BMSPersistenceHandler.java:136)
>
> at
> org.jpox.state.JDOStateManagerImpl.internalMakePersistent(JD OStateManagerImpl.java:3082)
>
> at
> org.jpox.state.JDOStateManagerImpl.makePersistent(JDOStateMa nagerImpl.java:3062)
>
> at
> org.jpox.ObjectManagerImpl.persistObjectInternal(ObjectManag erImpl.java:1231)
>
> at
> org.jpox.ObjectManagerImpl.persistObject(ObjectManagerImpl.j ava:1077)
> at
> org.jpox.jdo.AbstractPersistenceManager.jdoMakePersistent(Ab stractPersistenceManager.java:666)
>
> at
> org.jpox.jdo.AbstractPersistenceManager.makePersistent(Abstr actPersistenceManager.java:691)
>
>
> So again the casting error.
>
> I hope anyone can help me with that or does know what needs to be done.
> Again, thanks in advance.
>
>
> Regards
> Ziplies
>
>
> Martin Taal wrote:
>> Hi Ziplies,
>> Have you tried with jpox 1.1.9? That is the version currently working
>> with Teneo. It is clearly on my roadmap to upgrade to newer versions
>> of jpox/datanucleus. I have not yet had time to do so.
>>
>> If you get exceptions/errors can you post the stacktrace? That always
>> gives some more info.
>>
>> gr. Martin
>>
>> Savas Ziplies wrote:
>>> Hello,
>>>
>>> I am currently conducting some research on how to maybe change the
>>> software development workflow and structure in my institute. As I do
>>> not like too suffocating solutions I thought about some modelling
>>> approach through EMF, Teneo and DataNucleus.
>>>
>>> So I got myself everything needed, read all guides I could find on
>>> eclipse.org, elver.org and datanucleus.org and started with a basic
>>> model with basic relations. Everything worked so far as that I could
>>> - build the model (the example model from this site
>>> http://www.eclipse.org/gmt/oaw/doc/4.2/html/contents/emf_tut orial.html),
>>> - create the genmodel, - generated the code and even the
>>> - package.jdo. Everything got enhanced and then I thought I could
>>> start persisting everything... so I thought. All the time I get the
>>> error:
>>> java.lang.ClassCastException: org.datanucleus.sco.List cannot be cast
>>> to org.eclipse.emf.common.util.EList
>>>
>>> I looked it up, searched the newslists and forums but I couldn't figure
>>> out the solution. I know that there is probably an error about the
>>> implementing SCO for EList and DataNucleus, but I cannot figure out
>>> how to tell him what to use. I found tutorials about extensions and
>>> tried that but maybe I am just to slow for that. I do not really get the
>>> TypeMapping.
>>>
>>> The code is plain simple I think:
>>>
>>> PersistenceManagerFactory pmf =
>>> JDOHelper.getPersistenceManagerFactory("datanucleus.properties ");
>>> PersistenceManager pm = pmf.getPersistenceManager();
>>>
>>> Transaction tx = pm.currentTransaction();
>>> try {
>>> tx.begin();
>>>
>>> //
>>> DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
>>> datamodel.setName("DataModel");
>>>
>>> //
>>> pm.makePersistent(datamodel);
>>>
>>> tx.commit();
>>>
>>> } finally {
>>> if(tx.isActive()) {
>>> tx.rollback();
>>> }
>>> pm.close();
>>> }
>>>
>>> The tables are created in the database (a test MySQL DB). But
>>> pm.makePersistent(datamodel); kicks him out with the exception.
>>>
>>> I tried the creation with
>>>
>>> JpoxDataStore jpoxDataStore =
>>> JpoxHelper.INSTANCE.createRegisterDataStore("Data");
>>>
>>> but that throws errors from the beginning, as I think maybe something
>>> changed from Jpox to DataNucleus. So I tried older versions, before
>>> DataNucleus, so with Jpox directly, then the
>>> jpoxDataStore.initialize(); keeps getting errors.
>>>
>>> As you can see I am very desperate at the moment and I hope anyone
>>> can help me.
>>>
>>> Many many thanks in advance and thanks for every response.
>>>
>>>
>>> Regards
>>> Ziplies
>>>
>>>
>>> PS: I am using Eclipse 3.4M7 (but I have different installations
>>> with different plugins running, for testing purposes), EMF
>>> 2.4.0v200805052017 and Teneo 0.8.0v200804231747 with DataNucleus
>>> 1.0.0m1.
>>>
>>> The ecore model is following, the rest is generated through the
>>> described plugins
>>> plus my Test Class up above:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <ecore:EPackage xmi:version="2.0"
>>> xmlns:xmi="http://www.omg.org/XMI"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="data"
>>>
>>> nsURI="http://www.openarchitectureware.org/oaw4.demo.emf.datamodel"
>>> nsPrefix="data">
>>> <eClassifiers xsi:type="ecore:EClass" name="DataModel">
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="entity"
>>> upperBound="-1"
>>> eType="#//Entity" containment="true"/>
>>> </eClassifiers>
>>> <eClassifiers xsi:type="ecore:EClass" name="Entity">
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="attribute"
>>> lowerBound="1"
>>> upperBound="-1" eType="#//Attribute" containment="true"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="reference"
>>> upperBound="-1"
>>> eType="#//EntityReference" containment="true"/>
>>> </eClassifiers>
>>> <eClassifiers xsi:type="ecore:EClass" name="Attribute">
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> </eClassifiers>
>>> <eClassifiers xsi:type="ecore:EClass" name="EntityReference">
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="toMany"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="target"
>>> lowerBound="1"
>>> eType="#//Entity"/>
>>> </eClassifiers>
>>> </ecore:EPackage>
>>
>>


--

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: ClassCastException to EList [message #122795 is a reply to message #122790] Wed, 21 May 2008 18:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: insanitydesign.yahoo.de

Hi,

that was meant with no offense or something. I am maintaning myself several projects and I understand you more than you might think.

So, keep up the good work and sometime we'll see what we need. Thx!

Regards


Martin Taal wrote:
> Hi Ziplies,
> Jpox has made a lot of internal api changes going from 1.1.9 to 1.2. I
> have not yet had the time to upgrade Teneo to jpox 1.2 (as Teneo uses
> the internal jpox api). This is a fair amount of work which I need to
> look at in more detail. Also I was a bit reluctant because going to jpox
> 1.2 means that all current jpox-teneo users also needed to upgrade to
> 1.2. I don't have the capacity to maintain multiple Teneo branches for
> different versions of jpox.
> Teneo-Jpox has about 85 testcases which are run in 2 scenarios. If I run
> these testcases on jpox 1.2 then about half will fail. So before it
> makes sense for you to test it I would first need to get all the
> testcases to pass...
>
> The only thing you can do at the moment is be patient and add your name
> to the bugzilla for this to get an update on what happens:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=195434
>
> gr. Martin
>
> Savas Ziplies wrote:
>> Hi,
>>
>> so after I always tested with Jpox1.2.2 or DataNucleus1.0.0m1 I got it
>> to work with Jpox1.1.9, like you proposed. First of all thanks for that!
>> Now I got Eclipse3.3.2 running with EMF2.3.2, Teneo I0.8.0 and Jpox1.1.9.
>> But, I was eager to know why since Jpox1.2.0 it is not running
>> anymore, because from Version 1.2 beginning I get different errors,
>> and maybe you can help to fix them or can use them as BugReports.
>>
>> So, the same configuration (Eclipse3.3.2 running with EMF2.3.2, Teneo
>> I0.8.0) with Jpox1.2.0 gives me two differnt errors on different
>> approaches. First:
>> If I try to initialize in 1.2.0 with
>> //
>> Properties properties = new Properties();
>> properties.setProperty("javax.jdo.option.ConnectionDriverName ",
>> "com.mysql.jdbc.Driver");
>> properties.setProperty("javax.jdo.option.ConnectionURL",
>> "jdbc:mysql://127.0.0.1:3306/emf_jpox122");
>> properties.setProperty("javax.jdo.option.ConnectionUserName ", "root");
>> properties.setProperty("javax.jdo.option.ConnectionPassword ",
>> "vertrigo");
>>
>> //
>> String pmfName = "emf"; // the name of the JpoxDataStore
>> JpoxDataStore jpoxDataStore =
>> JpoxHelper.INSTANCE.createRegisterDataStore(pmfName);
>> jpoxDataStore.setProperties(properties);
>> jpoxDataStore.setEPackages(new EPackage[]{DataPackage.eINSTANCE});
>> jpoxDataStore.initialize();
>>
>> the line jpoxDataStore.initialize(); is throwing the following exception:
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> org/jpox/AbstractPersistenceManagerFactory
>> at
>> org.eclipse.emf.teneo.jpox.JpoxDataStore.createSchema(JpoxDa taStore.java:536)
>>
>> at
>> org.eclipse.emf.teneo.jpox.JpoxDataStore.initialize(JpoxData Store.java:228)
>>
>> at Run.<init>(Run.java:64)
>> at Run.main(Run.java:30)
>> Caused by: java.lang.ClassNotFoundException:
>> org.jpox.AbstractPersistenceManagerFactory
>> at java.net.URLClassLoader$1.run(Unknown Source)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at java.net.URLClassLoader.findClass(Unknown Source)
>> at java.lang.ClassLoader.loadClass(Unknown Source)
>> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>> at java.lang.ClassLoader.loadClass(Unknown Source)
>> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
>> ... 4 more
>>
>> So I tried to initialize everything by the lines:
>> PersistenceManagerFactory pmf =
>> JDOHelper.getPersistenceManagerFactory("jpox.properties");
>> PersistenceManager pm = pmf.getPersistenceManager();
>>
>> with the jpox.properties:
>> javax.jdo.PersistenceManagerFactoryClass=org.jpox.jdo.JDOPer sistenceManagerFactory
>>
>> javax.jdo.option.ConnectionDriverName=com.mysql.jdbc.Driver
>> javax.jdo.option.ConnectionURL=jdbc:mysql://127.0.0.1/emf_jpox122
>> javax.jdo.option.ConnectionUserName=root
>> javax.jdo.option.ConnectionPassword=vertrigo
>> org.jpox.autoCreateTables=true
>> org.jpox.autoCreateSchema=true
>> org.jpox.validateTables=false
>> org.jpox.validateConstraints=false
>>
>> and it starts and even creates all tables, but as soon as I create an
>> object and try to persist it with:
>> Transaction tx = pm.currentTransaction();
>> try {
>> tx.begin();
>>
>> //Create Entity
>> Entity entity = DataFactory.eINSTANCE.createEntity();
>> entity.setName("Entity");
>>
>> //Create DataModel
>> DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
>> datamodel.setName("DataModel");
>> datamodel.getEntity().add(entity);
>> //
>> pm.makePersistent(datamodel);
>>
>> tx.commit();
>>
>> } finally {
>> if(tx.isActive()) {
>> tx.rollback();
>> }
>> pm.close();
>> }
>>
>> pm.makePersistent(datamodel); throws the following exception:
>> java.lang.ClassCastException: org.jpox.sco.List cannot be cast to
>> org.eclipse.emf.common.util.EList
>> at data.impl.EntityImpl.jdoReplaceField(EntityImpl.java)
>> at
>> org.jpox.state.JDOStateManagerImpl.replaceField(JDOStateMana gerImpl.java:2546)
>>
>> at
>> org.jpox.state.JDOStateManagerImpl.replaceField(JDOStateMana gerImpl.java:2425)
>>
>> at org.jpox.sco.SCOUtils.newSCOInstance(SCOUtils.java:173)
>> at
>> org.jpox.store.mapped.mapping.AbstractContainerMapping.repla ceFieldWithWrapper(AbstractContainerMapping.java:394)
>>
>> at
>> org.jpox.store.mapped.mapping.CollectionMapping.postInsert(C ollectionMapping.java:103)
>>
>> at
>> org.jpox.store.rdbms.request.InsertRequest.execute(InsertReq uest.java:465)
>>
>> at
>> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertTable(RDB MSPersistenceHandler.java:157)
>>
>> at
>> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertObject(RD BMSPersistenceHandler.java:136)
>>
>> at
>> org.jpox.state.JDOStateManagerImpl.internalMakePersistent(JD OStateManagerImpl.java:3082)
>>
>> at
>> org.jpox.state.JDOStateManagerImpl.makePersistent(JDOStateMa nagerImpl.java:3062)
>>
>> at
>> org.jpox.ObjectManagerImpl.persistObjectInternal(ObjectManag erImpl.java:1231)
>>
>> at org.jpox.sco.SCOUtils.validateObjectForWriting(SCOUtils.java :1491)
>> at
>> org.jpox.store.rdbms.scostore.ElementContainerStore.validate ElementForWriting(ElementContainerStore.java:379)
>>
>> at
>> org.jpox.store.rdbms.scostore.FKListStore.validateElementFor Writing(FKListStore.java:1303)
>>
>> at
>> org.jpox.store.rdbms.scostore.FKListStore.internalAdd(FKList Store.java:830)
>>
>> at
>> org.jpox.store.rdbms.scostore.AbstractListStore.addAll(Abstr actListStore.java:354)
>>
>> at
>> org.jpox.store.mapped.mapping.CollectionMapping.postInsert(C ollectionMapping.java:158)
>>
>> at
>> org.jpox.store.rdbms.request.InsertRequest.execute(InsertReq uest.java:465)
>>
>> at
>> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertTable(RDB MSPersistenceHandler.java:157)
>>
>> at
>> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertObject(RD BMSPersistenceHandler.java:136)
>>
>> at
>> org.jpox.state.JDOStateManagerImpl.internalMakePersistent(JD OStateManagerImpl.java:3082)
>>
>> at
>> org.jpox.state.JDOStateManagerImpl.makePersistent(JDOStateMa nagerImpl.java:3062)
>>
>> at
>> org.jpox.ObjectManagerImpl.persistObjectInternal(ObjectManag erImpl.java:1231)
>>
>> at
>> org.jpox.ObjectManagerImpl.persistObject(ObjectManagerImpl.j ava:1077)
>> at
>> org.jpox.jdo.AbstractPersistenceManager.jdoMakePersistent(Ab stractPersistenceManager.java:666)
>>
>> at
>> org.jpox.jdo.AbstractPersistenceManager.makePersistent(Abstr actPersistenceManager.java:691)
>>
>>
>> So again the casting error.
>>
>> I hope anyone can help me with that or does know what needs to be
>> done. Again, thanks in advance.
>>
>>
>> Regards
>> Ziplies
>>
>>
>> Martin Taal wrote:
>>> Hi Ziplies,
>>> Have you tried with jpox 1.1.9? That is the version currently working
>>> with Teneo. It is clearly on my roadmap to upgrade to newer versions
>>> of jpox/datanucleus. I have not yet had time to do so.
>>>
>>> If you get exceptions/errors can you post the stacktrace? That always
>>> gives some more info.
>>>
>>> gr. Martin
>>>
>>> Savas Ziplies wrote:
>>>> Hello,
>>>>
>>>> I am currently conducting some research on how to maybe change the
>>>> software development workflow and structure in my institute. As I do
>>>> not like too suffocating solutions I thought about some modelling
>>>> approach through EMF, Teneo and DataNucleus.
>>>>
>>>> So I got myself everything needed, read all guides I could find on
>>>> eclipse.org, elver.org and datanucleus.org and started with a basic
>>>> model with basic relations. Everything worked so far as that I could
>>>> - build the model (the example model from this site
>>>> http://www.eclipse.org/gmt/oaw/doc/4.2/html/contents/emf_tut orial.html),
>>>> - create the genmodel, - generated the code and even the
>>>> - package.jdo. Everything got enhanced and then I thought I could
>>>> start persisting everything... so I thought. All the time I get the
>>>> error:
>>>> java.lang.ClassCastException: org.datanucleus.sco.List cannot be cast
>>>> to org.eclipse.emf.common.util.EList
>>>>
>>>> I looked it up, searched the newslists and forums but I couldn't figure
>>>> out the solution. I know that there is probably an error about the
>>>> implementing SCO for EList and DataNucleus, but I cannot figure out
>>>> how to tell him what to use. I found tutorials about extensions and
>>>> tried that but maybe I am just to slow for that. I do not really get
>>>> the
>>>> TypeMapping.
>>>>
>>>> The code is plain simple I think:
>>>>
>>>> PersistenceManagerFactory pmf =
>>>> JDOHelper.getPersistenceManagerFactory("datanucleus.properties ");
>>>> PersistenceManager pm = pmf.getPersistenceManager();
>>>>
>>>> Transaction tx = pm.currentTransaction();
>>>> try {
>>>> tx.begin();
>>>>
>>>> //
>>>> DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
>>>> datamodel.setName("DataModel");
>>>>
>>>> //
>>>> pm.makePersistent(datamodel);
>>>>
>>>> tx.commit();
>>>>
>>>> } finally {
>>>> if(tx.isActive()) {
>>>> tx.rollback();
>>>> }
>>>> pm.close();
>>>> }
>>>>
>>>> The tables are created in the database (a test MySQL DB). But
>>>> pm.makePersistent(datamodel); kicks him out with the exception.
>>>>
>>>> I tried the creation with
>>>>
>>>> JpoxDataStore jpoxDataStore =
>>>> JpoxHelper.INSTANCE.createRegisterDataStore("Data");
>>>>
>>>> but that throws errors from the beginning, as I think maybe something
>>>> changed from Jpox to DataNucleus. So I tried older versions, before
>>>> DataNucleus, so with Jpox directly, then the
>>>> jpoxDataStore.initialize(); keeps getting errors.
>>>>
>>>> As you can see I am very desperate at the moment and I hope anyone
>>>> can help me.
>>>>
>>>> Many many thanks in advance and thanks for every response.
>>>>
>>>>
>>>> Regards
>>>> Ziplies
>>>>
>>>>
>>>> PS: I am using Eclipse 3.4M7 (but I have different installations
>>>> with different plugins running, for testing purposes), EMF
>>>> 2.4.0v200805052017 and Teneo 0.8.0v200804231747 with DataNucleus
>>>> 1.0.0m1.
>>>>
>>>> The ecore model is following, the rest is generated through the
>>>> described plugins
>>>> plus my Test Class up above:
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <ecore:EPackage xmi:version="2.0"
>>>> xmlns:xmi="http://www.omg.org/XMI"
>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="data"
>>>>
>>>> nsURI="http://www.openarchitectureware.org/oaw4.demo.emf.datamodel"
>>>> nsPrefix="data">
>>>> <eClassifiers xsi:type="ecore:EClass" name="DataModel">
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>>> eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>> <eStructuralFeatures xsi:type="ecore:EReference" name="entity"
>>>> upperBound="-1"
>>>> eType="#//Entity" containment="true"/>
>>>> </eClassifiers>
>>>> <eClassifiers xsi:type="ecore:EClass" name="Entity">
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>>> eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>> <eStructuralFeatures xsi:type="ecore:EReference" name="attribute"
>>>> lowerBound="1"
>>>> upperBound="-1" eType="#//Attribute" containment="true"/>
>>>> <eStructuralFeatures xsi:type="ecore:EReference" name="reference"
>>>> upperBound="-1"
>>>> eType="#//EntityReference" containment="true"/>
>>>> </eClassifiers>
>>>> <eClassifiers xsi:type="ecore:EClass" name="Attribute">
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>>> eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
>>>> eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>> </eClassifiers>
>>>> <eClassifiers xsi:type="ecore:EClass" name="EntityReference">
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>>> eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="toMany"
>>>> eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
>>>> <eStructuralFeatures xsi:type="ecore:EReference" name="target"
>>>> lowerBound="1"
>>>> eType="#//Entity"/>
>>>> </eClassifiers>
>>>> </ecore:EPackage>
>>>
>>>
>
>
Re: ClassCastException to EList [message #122809 is a reply to message #122795] Wed, 21 May 2008 20:06 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Ziplies,
I didn't see an offense. I think you read more in my reply then I wrote into it/or ment to write
into it. With be patient (if that is what you reacted on) I mean that it will take me some time to
do this. More time than I like, but it is a fair amount of work getting 40 or so testcases back on
their feet.

If more people ask for the jpox upgrade the quicker it will happen so your post pointing out the
issues you are having is right on the spot and perfectly fine.

gr. Martin

Savas Ziplies wrote:
> Hi,
>
> that was meant with no offense or something. I am maintaning myself
> several projects and I understand you more than you might think.
>
> So, keep up the good work and sometime we'll see what we need. Thx!
>
> Regards
>
>
> Martin Taal wrote:
>> Hi Ziplies,
>> Jpox has made a lot of internal api changes going from 1.1.9 to 1.2. I
>> have not yet had the time to upgrade Teneo to jpox 1.2 (as Teneo uses
>> the internal jpox api). This is a fair amount of work which I need to
>> look at in more detail. Also I was a bit reluctant because going to
>> jpox 1.2 means that all current jpox-teneo users also needed to
>> upgrade to 1.2. I don't have the capacity to maintain multiple Teneo
>> branches for different versions of jpox.
>> Teneo-Jpox has about 85 testcases which are run in 2 scenarios. If I
>> run these testcases on jpox 1.2 then about half will fail. So before
>> it makes sense for you to test it I would first need to get all the
>> testcases to pass...
>>
>> The only thing you can do at the moment is be patient and add your
>> name to the bugzilla for this to get an update on what happens:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=195434
>>
>> gr. Martin
>>
>> Savas Ziplies wrote:
>>> Hi,
>>>
>>> so after I always tested with Jpox1.2.2 or DataNucleus1.0.0m1 I got
>>> it to work with Jpox1.1.9, like you proposed. First of all thanks for
>>> that!
>>> Now I got Eclipse3.3.2 running with EMF2.3.2, Teneo I0.8.0 and
>>> Jpox1.1.9.
>>> But, I was eager to know why since Jpox1.2.0 it is not running
>>> anymore, because from Version 1.2 beginning I get different errors,
>>> and maybe you can help to fix them or can use them as BugReports.
>>>
>>> So, the same configuration (Eclipse3.3.2 running with EMF2.3.2, Teneo
>>> I0.8.0) with Jpox1.2.0 gives me two differnt errors on different
>>> approaches. First:
>>> If I try to initialize in 1.2.0 with
>>> //
>>> Properties properties = new Properties();
>>> properties.setProperty("javax.jdo.option.ConnectionDriverName ",
>>> "com.mysql.jdbc.Driver");
>>> properties.setProperty("javax.jdo.option.ConnectionURL",
>>> "jdbc:mysql://127.0.0.1:3306/emf_jpox122");
>>> properties.setProperty("javax.jdo.option.ConnectionUserName ", "root");
>>> properties.setProperty("javax.jdo.option.ConnectionPassword ",
>>> "vertrigo");
>>>
>>> //
>>> String pmfName = "emf"; // the name of the JpoxDataStore
>>> JpoxDataStore jpoxDataStore =
>>> JpoxHelper.INSTANCE.createRegisterDataStore(pmfName);
>>> jpoxDataStore.setProperties(properties);
>>> jpoxDataStore.setEPackages(new EPackage[]{DataPackage.eINSTANCE});
>>> jpoxDataStore.initialize();
>>>
>>> the line jpoxDataStore.initialize(); is throwing the following
>>> exception:
>>> Exception in thread "main" java.lang.NoClassDefFoundError:
>>> org/jpox/AbstractPersistenceManagerFactory
>>> at
>>> org.eclipse.emf.teneo.jpox.JpoxDataStore.createSchema(JpoxDa taStore.java:536)
>>>
>>> at
>>> org.eclipse.emf.teneo.jpox.JpoxDataStore.initialize(JpoxData Store.java:228)
>>>
>>> at Run.<init>(Run.java:64)
>>> at Run.main(Run.java:30)
>>> Caused by: java.lang.ClassNotFoundException:
>>> org.jpox.AbstractPersistenceManagerFactory
>>> at java.net.URLClassLoader$1.run(Unknown Source)
>>> at java.security.AccessController.doPrivileged(Native Method)
>>> at java.net.URLClassLoader.findClass(Unknown Source)
>>> at java.lang.ClassLoader.loadClass(Unknown Source)
>>> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>>> at java.lang.ClassLoader.loadClass(Unknown Source)
>>> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
>>> ... 4 more
>>>
>>> So I tried to initialize everything by the lines:
>>> PersistenceManagerFactory pmf =
>>> JDOHelper.getPersistenceManagerFactory("jpox.properties");
>>> PersistenceManager pm = pmf.getPersistenceManager();
>>>
>>> with the jpox.properties:
>>> javax.jdo.PersistenceManagerFactoryClass=org.jpox.jdo.JDOPer sistenceManagerFactory
>>>
>>> javax.jdo.option.ConnectionDriverName=com.mysql.jdbc.Driver
>>> javax.jdo.option.ConnectionURL=jdbc:mysql://127.0.0.1/emf_jpox122
>>> javax.jdo.option.ConnectionUserName=root
>>> javax.jdo.option.ConnectionPassword=vertrigo
>>> org.jpox.autoCreateTables=true
>>> org.jpox.autoCreateSchema=true
>>> org.jpox.validateTables=false
>>> org.jpox.validateConstraints=false
>>>
>>> and it starts and even creates all tables, but as soon as I create an
>>> object and try to persist it with:
>>> Transaction tx = pm.currentTransaction();
>>> try {
>>> tx.begin();
>>>
>>> //Create Entity
>>> Entity entity = DataFactory.eINSTANCE.createEntity();
>>> entity.setName("Entity");
>>>
>>> //Create DataModel
>>> DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
>>> datamodel.setName("DataModel");
>>> datamodel.getEntity().add(entity);
>>> //
>>> pm.makePersistent(datamodel);
>>>
>>> tx.commit();
>>>
>>> } finally {
>>> if(tx.isActive()) {
>>> tx.rollback();
>>> }
>>> pm.close();
>>> }
>>>
>>> pm.makePersistent(datamodel); throws the following exception:
>>> java.lang.ClassCastException: org.jpox.sco.List cannot be cast to
>>> org.eclipse.emf.common.util.EList
>>> at data.impl.EntityImpl.jdoReplaceField(EntityImpl.java)
>>> at
>>> org.jpox.state.JDOStateManagerImpl.replaceField(JDOStateMana gerImpl.java:2546)
>>>
>>> at
>>> org.jpox.state.JDOStateManagerImpl.replaceField(JDOStateMana gerImpl.java:2425)
>>>
>>> at org.jpox.sco.SCOUtils.newSCOInstance(SCOUtils.java:173)
>>> at
>>> org.jpox.store.mapped.mapping.AbstractContainerMapping.repla ceFieldWithWrapper(AbstractContainerMapping.java:394)
>>>
>>> at
>>> org.jpox.store.mapped.mapping.CollectionMapping.postInsert(C ollectionMapping.java:103)
>>>
>>> at
>>> org.jpox.store.rdbms.request.InsertRequest.execute(InsertReq uest.java:465)
>>>
>>> at
>>> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertTable(RDB MSPersistenceHandler.java:157)
>>>
>>> at
>>> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertObject(RD BMSPersistenceHandler.java:136)
>>>
>>> at
>>> org.jpox.state.JDOStateManagerImpl.internalMakePersistent(JD OStateManagerImpl.java:3082)
>>>
>>> at
>>> org.jpox.state.JDOStateManagerImpl.makePersistent(JDOStateMa nagerImpl.java:3062)
>>>
>>> at
>>> org.jpox.ObjectManagerImpl.persistObjectInternal(ObjectManag erImpl.java:1231)
>>>
>>> at
>>> org.jpox.sco.SCOUtils.validateObjectForWriting(SCOUtils.java :1491)
>>> at
>>> org.jpox.store.rdbms.scostore.ElementContainerStore.validate ElementForWriting(ElementContainerStore.java:379)
>>>
>>> at
>>> org.jpox.store.rdbms.scostore.FKListStore.validateElementFor Writing(FKListStore.java:1303)
>>>
>>> at
>>> org.jpox.store.rdbms.scostore.FKListStore.internalAdd(FKList Store.java:830)
>>>
>>> at
>>> org.jpox.store.rdbms.scostore.AbstractListStore.addAll(Abstr actListStore.java:354)
>>>
>>> at
>>> org.jpox.store.mapped.mapping.CollectionMapping.postInsert(C ollectionMapping.java:158)
>>>
>>> at
>>> org.jpox.store.rdbms.request.InsertRequest.execute(InsertReq uest.java:465)
>>>
>>> at
>>> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertTable(RDB MSPersistenceHandler.java:157)
>>>
>>> at
>>> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertObject(RD BMSPersistenceHandler.java:136)
>>>
>>> at
>>> org.jpox.state.JDOStateManagerImpl.internalMakePersistent(JD OStateManagerImpl.java:3082)
>>>
>>> at
>>> org.jpox.state.JDOStateManagerImpl.makePersistent(JDOStateMa nagerImpl.java:3062)
>>>
>>> at
>>> org.jpox.ObjectManagerImpl.persistObjectInternal(ObjectManag erImpl.java:1231)
>>>
>>> at
>>> org.jpox.ObjectManagerImpl.persistObject(ObjectManagerImpl.j ava:1077)
>>> at
>>> org.jpox.jdo.AbstractPersistenceManager.jdoMakePersistent(Ab stractPersistenceManager.java:666)
>>>
>>> at
>>> org.jpox.jdo.AbstractPersistenceManager.makePersistent(Abstr actPersistenceManager.java:691)
>>>
>>>
>>> So again the casting error.
>>>
>>> I hope anyone can help me with that or does know what needs to be
>>> done. Again, thanks in advance.
>>>
>>>
>>> Regards
>>> Ziplies
>>>
>>>
>>> Martin Taal wrote:
>>>> Hi Ziplies,
>>>> Have you tried with jpox 1.1.9? That is the version currently
>>>> working with Teneo. It is clearly on my roadmap to upgrade to newer
>>>> versions of jpox/datanucleus. I have not yet had time to do so.
>>>>
>>>> If you get exceptions/errors can you post the stacktrace? That
>>>> always gives some more info.
>>>>
>>>> gr. Martin
>>>>
>>>> Savas Ziplies wrote:
>>>>> Hello,
>>>>>
>>>>> I am currently conducting some research on how to maybe change the
>>>>> software development workflow and structure in my institute. As I do
>>>>> not like too suffocating solutions I thought about some modelling
>>>>> approach through EMF, Teneo and DataNucleus.
>>>>>
>>>>> So I got myself everything needed, read all guides I could find on
>>>>> eclipse.org, elver.org and datanucleus.org and started with a basic
>>>>> model with basic relations. Everything worked so far as that I could
>>>>> - build the model (the example model from this site
>>>>> http://www.eclipse.org/gmt/oaw/doc/4.2/html/contents/emf_tut orial.html),
>>>>> - create the genmodel, - generated the code and even the
>>>>> - package.jdo. Everything got enhanced and then I thought I could
>>>>> start persisting everything... so I thought. All the time I get the
>>>>> error:
>>>>> java.lang.ClassCastException: org.datanucleus.sco.List cannot be cast
>>>>> to org.eclipse.emf.common.util.EList
>>>>>
>>>>> I looked it up, searched the newslists and forums but I couldn't
>>>>> figure
>>>>> out the solution. I know that there is probably an error about the
>>>>> implementing SCO for EList and DataNucleus, but I cannot figure out
>>>>> how to tell him what to use. I found tutorials about extensions and
>>>>> tried that but maybe I am just to slow for that. I do not really
>>>>> get the
>>>>> TypeMapping.
>>>>>
>>>>> The code is plain simple I think:
>>>>>
>>>>> PersistenceManagerFactory pmf =
>>>>> JDOHelper.getPersistenceManagerFactory("datanucleus.properties ");
>>>>> PersistenceManager pm = pmf.getPersistenceManager();
>>>>>
>>>>> Transaction tx = pm.currentTransaction();
>>>>> try {
>>>>> tx.begin();
>>>>>
>>>>> //
>>>>> DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
>>>>> datamodel.setName("DataModel");
>>>>>
>>>>> //
>>>>> pm.makePersistent(datamodel);
>>>>>
>>>>> tx.commit();
>>>>>
>>>>> } finally {
>>>>> if(tx.isActive()) {
>>>>> tx.rollback();
>>>>> }
>>>>> pm.close();
>>>>> }
>>>>>
>>>>> The tables are created in the database (a test MySQL DB). But
>>>>> pm.makePersistent(datamodel); kicks him out with the exception.
>>>>>
>>>>> I tried the creation with
>>>>>
>>>>> JpoxDataStore jpoxDataStore =
>>>>> JpoxHelper.INSTANCE.createRegisterDataStore("Data");
>>>>>
>>>>> but that throws errors from the beginning, as I think maybe something
>>>>> changed from Jpox to DataNucleus. So I tried older versions, before
>>>>> DataNucleus, so with Jpox directly, then the
>>>>> jpoxDataStore.initialize(); keeps getting errors.
>>>>>
>>>>> As you can see I am very desperate at the moment and I hope anyone
>>>>> can help me.
>>>>>
>>>>> Many many thanks in advance and thanks for every response.
>>>>>
>>>>>
>>>>> Regards
>>>>> Ziplies
>>>>>
>>>>>
>>>>> PS: I am using Eclipse 3.4M7 (but I have different installations
>>>>> with different plugins running, for testing purposes), EMF
>>>>> 2.4.0v200805052017 and Teneo 0.8.0v200804231747 with DataNucleus
>>>>> 1.0.0m1.
>>>>>
>>>>> The ecore model is following, the rest is generated through the
>>>>> described plugins
>>>>> plus my Test Class up above:
>>>>>
>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>> <ecore:EPackage xmi:version="2.0"
>>>>> xmlns:xmi="http://www.omg.org/XMI"
>>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="data"
>>>>>
>>>>> nsURI="http://www.openarchitectureware.org/oaw4.demo.emf.datamodel"
>>>>> nsPrefix="data">
>>>>> <eClassifiers xsi:type="ecore:EClass" name="DataModel">
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>>>> eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>> <eStructuralFeatures xsi:type="ecore:EReference" name="entity"
>>>>> upperBound="-1"
>>>>> eType="#//Entity" containment="true"/>
>>>>> </eClassifiers>
>>>>> <eClassifiers xsi:type="ecore:EClass" name="Entity">
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>>>> eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>> <eStructuralFeatures xsi:type="ecore:EReference"
>>>>> name="attribute" lowerBound="1"
>>>>> upperBound="-1" eType="#//Attribute" containment="true"/>
>>>>> <eStructuralFeatures xsi:type="ecore:EReference"
>>>>> name="reference" upperBound="-1"
>>>>> eType="#//EntityReference" containment="true"/>
>>>>> </eClassifiers>
>>>>> <eClassifiers xsi:type="ecore:EClass" name="Attribute">
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>>>> eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
>>>>> eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>> </eClassifiers>
>>>>> <eClassifiers xsi:type="ecore:EClass" name="EntityReference">
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>>>> eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="toMany"
>>>>> eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
>>>>> <eStructuralFeatures xsi:type="ecore:EReference" name="target"
>>>>> lowerBound="1"
>>>>> eType="#//Entity"/>
>>>>> </eClassifiers>
>>>>> </ecore:EPackage>
>>>>
>>>>
>>
>>


--

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: ClassCastException to EList [message #618078 is a reply to message #122721] Tue, 20 May 2008 21:17 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Ziplies,
Have you tried with jpox 1.1.9? That is the version currently working with Teneo. It is clearly on
my roadmap to upgrade to newer versions of jpox/datanucleus. I have not yet had time to do so.

If you get exceptions/errors can you post the stacktrace? That always gives some more info.

gr. Martin

Savas Ziplies wrote:
> Hello,
>
> I am currently conducting some research on how to maybe change the
> software development workflow and structure in my institute. As I do
> not like too suffocating solutions I thought about some modelling
> approach through EMF, Teneo and DataNucleus.
>
> So I got myself everything needed, read all guides I could find on
> eclipse.org, elver.org and datanucleus.org and started with a basic
> model with basic relations. Everything worked so far as that I could
> - build the model (the example model from this site
> http://www.eclipse.org/gmt/oaw/doc/4.2/html/contents/emf_tut orial.html),
> - create the genmodel, - generated the code and even the
> - package.jdo. Everything got enhanced and then I thought I could start
> persisting everything... so I thought. All the time I get the error:
> java.lang.ClassCastException: org.datanucleus.sco.List cannot be cast
> to org.eclipse.emf.common.util.EList
>
> I looked it up, searched the newslists and forums but I couldn't figure
> out the solution. I know that there is probably an error about the
> implementing SCO for EList and DataNucleus, but I cannot figure out
> how to tell him what to use. I found tutorials about extensions and
> tried that but maybe I am just to slow for that. I do not really get the
> TypeMapping.
>
> The code is plain simple I think:
>
> PersistenceManagerFactory pmf =
> JDOHelper.getPersistenceManagerFactory("datanucleus.properties ");
> PersistenceManager pm = pmf.getPersistenceManager();
>
> Transaction tx = pm.currentTransaction();
> try {
> tx.begin();
>
> //
> DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
> datamodel.setName("DataModel");
>
> //
> pm.makePersistent(datamodel);
>
> tx.commit();
>
> } finally {
> if(tx.isActive()) {
> tx.rollback();
> }
> pm.close();
> }
>
> The tables are created in the database (a test MySQL DB). But
> pm.makePersistent(datamodel); kicks him out with the exception.
>
> I tried the creation with
>
> JpoxDataStore jpoxDataStore =
> JpoxHelper.INSTANCE.createRegisterDataStore("Data");
>
> but that throws errors from the beginning, as I think maybe something
> changed from Jpox to DataNucleus. So I tried older versions, before
> DataNucleus, so with Jpox directly, then the jpoxDataStore.initialize();
> keeps getting errors.
>
> As you can see I am very desperate at the moment and I hope anyone can
> help me.
>
> Many many thanks in advance and thanks for every response.
>
>
> Regards
> Ziplies
>
>
> PS: I am using Eclipse 3.4M7 (but I have different installations
> with different plugins running, for testing purposes), EMF
> 2.4.0v200805052017 and Teneo 0.8.0v200804231747 with DataNucleus 1.0.0m1.
>
> The ecore model is following, the rest is generated through the
> described plugins
> plus my Test Class up above:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="data"
> nsURI="http://www.openarchitectureware.org/oaw4.demo.emf.datamodel"
> nsPrefix="data">
> <eClassifiers xsi:type="ecore:EClass" name="DataModel">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="entity"
> upperBound="-1"
> eType="#//Entity" containment="true"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Entity">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="attribute"
> lowerBound="1"
> upperBound="-1" eType="#//Attribute" containment="true"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="reference"
> upperBound="-1"
> eType="#//EntityReference" containment="true"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Attribute">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="EntityReference">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="toMany"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="target"
> lowerBound="1"
> eType="#//Entity"/>
> </eClassifiers>
> </ecore:EPackage>


--

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: ClassCastException to EList [message #618101 is a reply to message #122726] Wed, 21 May 2008 16:01 Go to previous message
Eclipse UserFriend
Originally posted by: insanitydesign.yahoo.de

Hi,

so after I always tested with Jpox1.2.2 or DataNucleus1.0.0m1 I got it to work with Jpox1.1.9, like you proposed. First of all thanks for that!
Now I got Eclipse3.3.2 running with EMF2.3.2, Teneo I0.8.0 and Jpox1.1.9.

But, I was eager to know why since Jpox1.2.0 it is not running anymore, because from Version 1.2 beginning I get different errors, and maybe you can help to fix them or can use them as BugReports.

So, the same configuration (Eclipse3.3.2 running with EMF2.3.2, Teneo I0.8.0) with Jpox1.2.0 gives me two differnt errors on different approaches.
First:
If I try to initialize in 1.2.0 with
//
Properties properties = new Properties();
properties.setProperty("javax.jdo.option.ConnectionDriverName ", "com.mysql.jdbc.Driver");
properties.setProperty("javax.jdo.option.ConnectionURL", "jdbc:mysql://127.0.0.1:3306/emf_jpox122");
properties.setProperty("javax.jdo.option.ConnectionUserName ", "root");
properties.setProperty("javax.jdo.option.ConnectionPassword ", "vertrigo");

//
String pmfName = "emf"; // the name of the JpoxDataStore
JpoxDataStore jpoxDataStore = JpoxHelper.INSTANCE.createRegisterDataStore(pmfName);
jpoxDataStore.setProperties(properties);
jpoxDataStore.setEPackages(new EPackage[]{DataPackage.eINSTANCE});
jpoxDataStore.initialize();

the line jpoxDataStore.initialize(); is throwing the following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/jpox/AbstractPersistenceManagerFactory
at org.eclipse.emf.teneo.jpox.JpoxDataStore.createSchema(JpoxDa taStore.java:536)
at org.eclipse.emf.teneo.jpox.JpoxDataStore.initialize(JpoxData Store.java:228)
at Run.<init>(Run.java:64)
at Run.main(Run.java:30)
Caused by: java.lang.ClassNotFoundException: org.jpox.AbstractPersistenceManagerFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 4 more

So I tried to initialize everything by the lines:
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("jpox.properties");
PersistenceManager pm = pmf.getPersistenceManager();

with the jpox.properties:
javax.jdo.PersistenceManagerFactoryClass=org.jpox.jdo.JDOPer sistenceManagerFactory
javax.jdo.option.ConnectionDriverName=com.mysql.jdbc.Driver
javax.jdo.option.ConnectionURL=jdbc:mysql://127.0.0.1/emf_jpox122
javax.jdo.option.ConnectionUserName=root
javax.jdo.option.ConnectionPassword=vertrigo
org.jpox.autoCreateTables=true
org.jpox.autoCreateSchema=true
org.jpox.validateTables=false
org.jpox.validateConstraints=false

and it starts and even creates all tables, but as soon as I create an object and try to persist it with:
Transaction tx = pm.currentTransaction();
try {
tx.begin();

//Create Entity
Entity entity = DataFactory.eINSTANCE.createEntity();
entity.setName("Entity");

//Create DataModel
DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
datamodel.setName("DataModel");
datamodel.getEntity().add(entity);

//
pm.makePersistent(datamodel);

tx.commit();

} finally {
if(tx.isActive()) {
tx.rollback();
}
pm.close();
}

pm.makePersistent(datamodel); throws the following exception:
java.lang.ClassCastException: org.jpox.sco.List cannot be cast to org.eclipse.emf.common.util.EList
at data.impl.EntityImpl.jdoReplaceField(EntityImpl.java)
at org.jpox.state.JDOStateManagerImpl.replaceField(JDOStateMana gerImpl.java:2546)
at org.jpox.state.JDOStateManagerImpl.replaceField(JDOStateMana gerImpl.java:2425)
at org.jpox.sco.SCOUtils.newSCOInstance(SCOUtils.java:173)
at org.jpox.store.mapped.mapping.AbstractContainerMapping.repla ceFieldWithWrapper(AbstractContainerMapping.java:394)
at org.jpox.store.mapped.mapping.CollectionMapping.postInsert(C ollectionMapping.java:103)
at org.jpox.store.rdbms.request.InsertRequest.execute(InsertReq uest.java:465)
at org.jpox.store.rdbms.RDBMSPersistenceHandler.insertTable(RDB MSPersistenceHandler.java:157)
at org.jpox.store.rdbms.RDBMSPersistenceHandler.insertObject(RD BMSPersistenceHandler.java:136)
at org.jpox.state.JDOStateManagerImpl.internalMakePersistent(JD OStateManagerImpl.java:3082)
at org.jpox.state.JDOStateManagerImpl.makePersistent(JDOStateMa nagerImpl.java:3062)
at org.jpox.ObjectManagerImpl.persistObjectInternal(ObjectManag erImpl.java:1231)
at org.jpox.sco.SCOUtils.validateObjectForWriting(SCOUtils.java :1491)
at org.jpox.store.rdbms.scostore.ElementContainerStore.validate ElementForWriting(ElementContainerStore.java:379)
at org.jpox.store.rdbms.scostore.FKListStore.validateElementFor Writing(FKListStore.java:1303)
at org.jpox.store.rdbms.scostore.FKListStore.internalAdd(FKList Store.java:830)
at org.jpox.store.rdbms.scostore.AbstractListStore.addAll(Abstr actListStore.java:354)
at org.jpox.store.mapped.mapping.CollectionMapping.postInsert(C ollectionMapping.java:158)
at org.jpox.store.rdbms.request.InsertRequest.execute(InsertReq uest.java:465)
at org.jpox.store.rdbms.RDBMSPersistenceHandler.insertTable(RDB MSPersistenceHandler.java:157)
at org.jpox.store.rdbms.RDBMSPersistenceHandler.insertObject(RD BMSPersistenceHandler.java:136)
at org.jpox.state.JDOStateManagerImpl.internalMakePersistent(JD OStateManagerImpl.java:3082)
at org.jpox.state.JDOStateManagerImpl.makePersistent(JDOStateMa nagerImpl.java:3062)
at org.jpox.ObjectManagerImpl.persistObjectInternal(ObjectManag erImpl.java:1231)
at org.jpox.ObjectManagerImpl.persistObject(ObjectManagerImpl.j ava:1077)
at org.jpox.jdo.AbstractPersistenceManager.jdoMakePersistent(Ab stractPersistenceManager.java:666)
at org.jpox.jdo.AbstractPersistenceManager.makePersistent(Abstr actPersistenceManager.java:691)

So again the casting error.

I hope anyone can help me with that or does know what needs to be done. Again, thanks in advance.


Regards
Ziplies


Martin Taal wrote:
> Hi Ziplies,
> Have you tried with jpox 1.1.9? That is the version currently working
> with Teneo. It is clearly on my roadmap to upgrade to newer versions of
> jpox/datanucleus. I have not yet had time to do so.
>
> If you get exceptions/errors can you post the stacktrace? That always
> gives some more info.
>
> gr. Martin
>
> Savas Ziplies wrote:
>> Hello,
>>
>> I am currently conducting some research on how to maybe change the
>> software development workflow and structure in my institute. As I do
>> not like too suffocating solutions I thought about some modelling
>> approach through EMF, Teneo and DataNucleus.
>>
>> So I got myself everything needed, read all guides I could find on
>> eclipse.org, elver.org and datanucleus.org and started with a basic
>> model with basic relations. Everything worked so far as that I could
>> - build the model (the example model from this site
>> http://www.eclipse.org/gmt/oaw/doc/4.2/html/contents/emf_tut orial.html),
>> - create the genmodel, - generated the code and even the
>> - package.jdo. Everything got enhanced and then I thought I could
>> start persisting everything... so I thought. All the time I get the
>> error:
>> java.lang.ClassCastException: org.datanucleus.sco.List cannot be cast
>> to org.eclipse.emf.common.util.EList
>>
>> I looked it up, searched the newslists and forums but I couldn't figure
>> out the solution. I know that there is probably an error about the
>> implementing SCO for EList and DataNucleus, but I cannot figure out
>> how to tell him what to use. I found tutorials about extensions and
>> tried that but maybe I am just to slow for that. I do not really get the
>> TypeMapping.
>>
>> The code is plain simple I think:
>>
>> PersistenceManagerFactory pmf =
>> JDOHelper.getPersistenceManagerFactory("datanucleus.properties ");
>> PersistenceManager pm = pmf.getPersistenceManager();
>>
>> Transaction tx = pm.currentTransaction();
>> try {
>> tx.begin();
>>
>> //
>> DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
>> datamodel.setName("DataModel");
>>
>> //
>> pm.makePersistent(datamodel);
>>
>> tx.commit();
>>
>> } finally {
>> if(tx.isActive()) {
>> tx.rollback();
>> }
>> pm.close();
>> }
>>
>> The tables are created in the database (a test MySQL DB). But
>> pm.makePersistent(datamodel); kicks him out with the exception.
>>
>> I tried the creation with
>>
>> JpoxDataStore jpoxDataStore =
>> JpoxHelper.INSTANCE.createRegisterDataStore("Data");
>>
>> but that throws errors from the beginning, as I think maybe something
>> changed from Jpox to DataNucleus. So I tried older versions, before
>> DataNucleus, so with Jpox directly, then the
>> jpoxDataStore.initialize(); keeps getting errors.
>>
>> As you can see I am very desperate at the moment and I hope anyone can
>> help me.
>>
>> Many many thanks in advance and thanks for every response.
>>
>>
>> Regards
>> Ziplies
>>
>>
>> PS: I am using Eclipse 3.4M7 (but I have different installations
>> with different plugins running, for testing purposes), EMF
>> 2.4.0v200805052017 and Teneo 0.8.0v200804231747 with DataNucleus 1.0.0m1.
>>
>> The ecore model is following, the rest is generated through the
>> described plugins
>> plus my Test Class up above:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <ecore:EPackage xmi:version="2.0"
>> xmlns:xmi="http://www.omg.org/XMI"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="data"
>> nsURI="http://www.openarchitectureware.org/oaw4.demo.emf.datamodel"
>> nsPrefix="data">
>> <eClassifiers xsi:type="ecore:EClass" name="DataModel">
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="entity"
>> upperBound="-1"
>> eType="#//Entity" containment="true"/>
>> </eClassifiers>
>> <eClassifiers xsi:type="ecore:EClass" name="Entity">
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="attribute"
>> lowerBound="1"
>> upperBound="-1" eType="#//Attribute" containment="true"/>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="reference"
>> upperBound="-1"
>> eType="#//EntityReference" containment="true"/>
>> </eClassifiers>
>> <eClassifiers xsi:type="ecore:EClass" name="Attribute">
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>> </eClassifiers>
>> <eClassifiers xsi:type="ecore:EClass" name="EntityReference">
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="toMany"
>> eType="ecore:EDataType
>> http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="target"
>> lowerBound="1"
>> eType="#//Entity"/>
>> </eClassifiers>
>> </ecore:EPackage>
>
>
Re: ClassCastException to EList [message #618103 is a reply to message #122784] Wed, 21 May 2008 16:54 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Ziplies,
Jpox has made a lot of internal api changes going from 1.1.9 to 1.2. I have not yet had the time to
upgrade Teneo to jpox 1.2 (as Teneo uses the internal jpox api). This is a fair amount of work which
I need to look at in more detail. Also I was a bit reluctant because going to jpox 1.2 means that
all current jpox-teneo users also needed to upgrade to 1.2. I don't have the capacity to maintain
multiple Teneo branches for different versions of jpox.
Teneo-Jpox has about 85 testcases which are run in 2 scenarios. If I run these testcases on jpox 1.2
then about half will fail. So before it makes sense for you to test it I would first need to get all
the testcases to pass...

The only thing you can do at the moment is be patient and add your name to the bugzilla for this to
get an update on what happens:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=195434

gr. Martin

Savas Ziplies wrote:
> Hi,
>
> so after I always tested with Jpox1.2.2 or DataNucleus1.0.0m1 I got it
> to work with Jpox1.1.9, like you proposed. First of all thanks for that!
> Now I got Eclipse3.3.2 running with EMF2.3.2, Teneo I0.8.0 and Jpox1.1.9.
> But, I was eager to know why since Jpox1.2.0 it is not running anymore,
> because from Version 1.2 beginning I get different errors, and maybe you
> can help to fix them or can use them as BugReports.
>
> So, the same configuration (Eclipse3.3.2 running with EMF2.3.2, Teneo
> I0.8.0) with Jpox1.2.0 gives me two differnt errors on different
> approaches. First:
> If I try to initialize in 1.2.0 with
> //
> Properties properties = new Properties();
> properties.setProperty("javax.jdo.option.ConnectionDriverName ",
> "com.mysql.jdbc.Driver");
> properties.setProperty("javax.jdo.option.ConnectionURL",
> "jdbc:mysql://127.0.0.1:3306/emf_jpox122");
> properties.setProperty("javax.jdo.option.ConnectionUserName ", "root");
> properties.setProperty("javax.jdo.option.ConnectionPassword ", "vertrigo");
>
> //
> String pmfName = "emf"; // the name of the JpoxDataStore
> JpoxDataStore jpoxDataStore =
> JpoxHelper.INSTANCE.createRegisterDataStore(pmfName);
> jpoxDataStore.setProperties(properties);
> jpoxDataStore.setEPackages(new EPackage[]{DataPackage.eINSTANCE});
> jpoxDataStore.initialize();
>
> the line jpoxDataStore.initialize(); is throwing the following exception:
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/jpox/AbstractPersistenceManagerFactory
> at
> org.eclipse.emf.teneo.jpox.JpoxDataStore.createSchema(JpoxDa taStore.java:536)
>
> at
> org.eclipse.emf.teneo.jpox.JpoxDataStore.initialize(JpoxData Store.java:228)
> at Run.<init>(Run.java:64)
> at Run.main(Run.java:30)
> Caused by: java.lang.ClassNotFoundException:
> org.jpox.AbstractPersistenceManagerFactory
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
> ... 4 more
>
> So I tried to initialize everything by the lines:
> PersistenceManagerFactory pmf =
> JDOHelper.getPersistenceManagerFactory("jpox.properties");
> PersistenceManager pm = pmf.getPersistenceManager();
>
> with the jpox.properties:
> javax.jdo.PersistenceManagerFactoryClass=org.jpox.jdo.JDOPer sistenceManagerFactory
>
> javax.jdo.option.ConnectionDriverName=com.mysql.jdbc.Driver
> javax.jdo.option.ConnectionURL=jdbc:mysql://127.0.0.1/emf_jpox122
> javax.jdo.option.ConnectionUserName=root
> javax.jdo.option.ConnectionPassword=vertrigo
> org.jpox.autoCreateTables=true
> org.jpox.autoCreateSchema=true
> org.jpox.validateTables=false
> org.jpox.validateConstraints=false
>
> and it starts and even creates all tables, but as soon as I create an
> object and try to persist it with:
> Transaction tx = pm.currentTransaction();
> try {
> tx.begin();
>
> //Create Entity
> Entity entity = DataFactory.eINSTANCE.createEntity();
> entity.setName("Entity");
>
> //Create DataModel
> DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
> datamodel.setName("DataModel");
> datamodel.getEntity().add(entity);
> //
> pm.makePersistent(datamodel);
>
> tx.commit();
>
> } finally {
> if(tx.isActive()) {
> tx.rollback();
> }
> pm.close();
> }
>
> pm.makePersistent(datamodel); throws the following exception:
> java.lang.ClassCastException: org.jpox.sco.List cannot be cast to
> org.eclipse.emf.common.util.EList
> at data.impl.EntityImpl.jdoReplaceField(EntityImpl.java)
> at
> org.jpox.state.JDOStateManagerImpl.replaceField(JDOStateMana gerImpl.java:2546)
>
> at
> org.jpox.state.JDOStateManagerImpl.replaceField(JDOStateMana gerImpl.java:2425)
>
> at org.jpox.sco.SCOUtils.newSCOInstance(SCOUtils.java:173)
> at
> org.jpox.store.mapped.mapping.AbstractContainerMapping.repla ceFieldWithWrapper(AbstractContainerMapping.java:394)
>
> at
> org.jpox.store.mapped.mapping.CollectionMapping.postInsert(C ollectionMapping.java:103)
>
> at
> org.jpox.store.rdbms.request.InsertRequest.execute(InsertReq uest.java:465)
> at
> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertTable(RDB MSPersistenceHandler.java:157)
>
> at
> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertObject(RD BMSPersistenceHandler.java:136)
>
> at
> org.jpox.state.JDOStateManagerImpl.internalMakePersistent(JD OStateManagerImpl.java:3082)
>
> at
> org.jpox.state.JDOStateManagerImpl.makePersistent(JDOStateMa nagerImpl.java:3062)
>
> at
> org.jpox.ObjectManagerImpl.persistObjectInternal(ObjectManag erImpl.java:1231)
>
> at org.jpox.sco.SCOUtils.validateObjectForWriting(SCOUtils.java :1491)
> at
> org.jpox.store.rdbms.scostore.ElementContainerStore.validate ElementForWriting(ElementContainerStore.java:379)
>
> at
> org.jpox.store.rdbms.scostore.FKListStore.validateElementFor Writing(FKListStore.java:1303)
>
> at
> org.jpox.store.rdbms.scostore.FKListStore.internalAdd(FKList Store.java:830)
> at
> org.jpox.store.rdbms.scostore.AbstractListStore.addAll(Abstr actListStore.java:354)
>
> at
> org.jpox.store.mapped.mapping.CollectionMapping.postInsert(C ollectionMapping.java:158)
>
> at
> org.jpox.store.rdbms.request.InsertRequest.execute(InsertReq uest.java:465)
> at
> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertTable(RDB MSPersistenceHandler.java:157)
>
> at
> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertObject(RD BMSPersistenceHandler.java:136)
>
> at
> org.jpox.state.JDOStateManagerImpl.internalMakePersistent(JD OStateManagerImpl.java:3082)
>
> at
> org.jpox.state.JDOStateManagerImpl.makePersistent(JDOStateMa nagerImpl.java:3062)
>
> at
> org.jpox.ObjectManagerImpl.persistObjectInternal(ObjectManag erImpl.java:1231)
>
> at
> org.jpox.ObjectManagerImpl.persistObject(ObjectManagerImpl.j ava:1077)
> at
> org.jpox.jdo.AbstractPersistenceManager.jdoMakePersistent(Ab stractPersistenceManager.java:666)
>
> at
> org.jpox.jdo.AbstractPersistenceManager.makePersistent(Abstr actPersistenceManager.java:691)
>
>
> So again the casting error.
>
> I hope anyone can help me with that or does know what needs to be done.
> Again, thanks in advance.
>
>
> Regards
> Ziplies
>
>
> Martin Taal wrote:
>> Hi Ziplies,
>> Have you tried with jpox 1.1.9? That is the version currently working
>> with Teneo. It is clearly on my roadmap to upgrade to newer versions
>> of jpox/datanucleus. I have not yet had time to do so.
>>
>> If you get exceptions/errors can you post the stacktrace? That always
>> gives some more info.
>>
>> gr. Martin
>>
>> Savas Ziplies wrote:
>>> Hello,
>>>
>>> I am currently conducting some research on how to maybe change the
>>> software development workflow and structure in my institute. As I do
>>> not like too suffocating solutions I thought about some modelling
>>> approach through EMF, Teneo and DataNucleus.
>>>
>>> So I got myself everything needed, read all guides I could find on
>>> eclipse.org, elver.org and datanucleus.org and started with a basic
>>> model with basic relations. Everything worked so far as that I could
>>> - build the model (the example model from this site
>>> http://www.eclipse.org/gmt/oaw/doc/4.2/html/contents/emf_tut orial.html),
>>> - create the genmodel, - generated the code and even the
>>> - package.jdo. Everything got enhanced and then I thought I could
>>> start persisting everything... so I thought. All the time I get the
>>> error:
>>> java.lang.ClassCastException: org.datanucleus.sco.List cannot be cast
>>> to org.eclipse.emf.common.util.EList
>>>
>>> I looked it up, searched the newslists and forums but I couldn't figure
>>> out the solution. I know that there is probably an error about the
>>> implementing SCO for EList and DataNucleus, but I cannot figure out
>>> how to tell him what to use. I found tutorials about extensions and
>>> tried that but maybe I am just to slow for that. I do not really get the
>>> TypeMapping.
>>>
>>> The code is plain simple I think:
>>>
>>> PersistenceManagerFactory pmf =
>>> JDOHelper.getPersistenceManagerFactory("datanucleus.properties ");
>>> PersistenceManager pm = pmf.getPersistenceManager();
>>>
>>> Transaction tx = pm.currentTransaction();
>>> try {
>>> tx.begin();
>>>
>>> //
>>> DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
>>> datamodel.setName("DataModel");
>>>
>>> //
>>> pm.makePersistent(datamodel);
>>>
>>> tx.commit();
>>>
>>> } finally {
>>> if(tx.isActive()) {
>>> tx.rollback();
>>> }
>>> pm.close();
>>> }
>>>
>>> The tables are created in the database (a test MySQL DB). But
>>> pm.makePersistent(datamodel); kicks him out with the exception.
>>>
>>> I tried the creation with
>>>
>>> JpoxDataStore jpoxDataStore =
>>> JpoxHelper.INSTANCE.createRegisterDataStore("Data");
>>>
>>> but that throws errors from the beginning, as I think maybe something
>>> changed from Jpox to DataNucleus. So I tried older versions, before
>>> DataNucleus, so with Jpox directly, then the
>>> jpoxDataStore.initialize(); keeps getting errors.
>>>
>>> As you can see I am very desperate at the moment and I hope anyone
>>> can help me.
>>>
>>> Many many thanks in advance and thanks for every response.
>>>
>>>
>>> Regards
>>> Ziplies
>>>
>>>
>>> PS: I am using Eclipse 3.4M7 (but I have different installations
>>> with different plugins running, for testing purposes), EMF
>>> 2.4.0v200805052017 and Teneo 0.8.0v200804231747 with DataNucleus
>>> 1.0.0m1.
>>>
>>> The ecore model is following, the rest is generated through the
>>> described plugins
>>> plus my Test Class up above:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <ecore:EPackage xmi:version="2.0"
>>> xmlns:xmi="http://www.omg.org/XMI"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="data"
>>>
>>> nsURI="http://www.openarchitectureware.org/oaw4.demo.emf.datamodel"
>>> nsPrefix="data">
>>> <eClassifiers xsi:type="ecore:EClass" name="DataModel">
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="entity"
>>> upperBound="-1"
>>> eType="#//Entity" containment="true"/>
>>> </eClassifiers>
>>> <eClassifiers xsi:type="ecore:EClass" name="Entity">
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="attribute"
>>> lowerBound="1"
>>> upperBound="-1" eType="#//Attribute" containment="true"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="reference"
>>> upperBound="-1"
>>> eType="#//EntityReference" containment="true"/>
>>> </eClassifiers>
>>> <eClassifiers xsi:type="ecore:EClass" name="Attribute">
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> </eClassifiers>
>>> <eClassifiers xsi:type="ecore:EClass" name="EntityReference">
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="toMany"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="target"
>>> lowerBound="1"
>>> eType="#//Entity"/>
>>> </eClassifiers>
>>> </ecore:EPackage>
>>
>>


--

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: ClassCastException to EList [message #618105 is a reply to message #122790] Wed, 21 May 2008 18:15 Go to previous message
Eclipse UserFriend
Originally posted by: insanitydesign.yahoo.de

Hi,

that was meant with no offense or something. I am maintaning myself several projects and I understand you more than you might think.

So, keep up the good work and sometime we'll see what we need. Thx!

Regards


Martin Taal wrote:
> Hi Ziplies,
> Jpox has made a lot of internal api changes going from 1.1.9 to 1.2. I
> have not yet had the time to upgrade Teneo to jpox 1.2 (as Teneo uses
> the internal jpox api). This is a fair amount of work which I need to
> look at in more detail. Also I was a bit reluctant because going to jpox
> 1.2 means that all current jpox-teneo users also needed to upgrade to
> 1.2. I don't have the capacity to maintain multiple Teneo branches for
> different versions of jpox.
> Teneo-Jpox has about 85 testcases which are run in 2 scenarios. If I run
> these testcases on jpox 1.2 then about half will fail. So before it
> makes sense for you to test it I would first need to get all the
> testcases to pass...
>
> The only thing you can do at the moment is be patient and add your name
> to the bugzilla for this to get an update on what happens:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=195434
>
> gr. Martin
>
> Savas Ziplies wrote:
>> Hi,
>>
>> so after I always tested with Jpox1.2.2 or DataNucleus1.0.0m1 I got it
>> to work with Jpox1.1.9, like you proposed. First of all thanks for that!
>> Now I got Eclipse3.3.2 running with EMF2.3.2, Teneo I0.8.0 and Jpox1.1.9.
>> But, I was eager to know why since Jpox1.2.0 it is not running
>> anymore, because from Version 1.2 beginning I get different errors,
>> and maybe you can help to fix them or can use them as BugReports.
>>
>> So, the same configuration (Eclipse3.3.2 running with EMF2.3.2, Teneo
>> I0.8.0) with Jpox1.2.0 gives me two differnt errors on different
>> approaches. First:
>> If I try to initialize in 1.2.0 with
>> //
>> Properties properties = new Properties();
>> properties.setProperty("javax.jdo.option.ConnectionDriverName ",
>> "com.mysql.jdbc.Driver");
>> properties.setProperty("javax.jdo.option.ConnectionURL",
>> "jdbc:mysql://127.0.0.1:3306/emf_jpox122");
>> properties.setProperty("javax.jdo.option.ConnectionUserName ", "root");
>> properties.setProperty("javax.jdo.option.ConnectionPassword ",
>> "vertrigo");
>>
>> //
>> String pmfName = "emf"; // the name of the JpoxDataStore
>> JpoxDataStore jpoxDataStore =
>> JpoxHelper.INSTANCE.createRegisterDataStore(pmfName);
>> jpoxDataStore.setProperties(properties);
>> jpoxDataStore.setEPackages(new EPackage[]{DataPackage.eINSTANCE});
>> jpoxDataStore.initialize();
>>
>> the line jpoxDataStore.initialize(); is throwing the following exception:
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> org/jpox/AbstractPersistenceManagerFactory
>> at
>> org.eclipse.emf.teneo.jpox.JpoxDataStore.createSchema(JpoxDa taStore.java:536)
>>
>> at
>> org.eclipse.emf.teneo.jpox.JpoxDataStore.initialize(JpoxData Store.java:228)
>>
>> at Run.<init>(Run.java:64)
>> at Run.main(Run.java:30)
>> Caused by: java.lang.ClassNotFoundException:
>> org.jpox.AbstractPersistenceManagerFactory
>> at java.net.URLClassLoader$1.run(Unknown Source)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at java.net.URLClassLoader.findClass(Unknown Source)
>> at java.lang.ClassLoader.loadClass(Unknown Source)
>> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>> at java.lang.ClassLoader.loadClass(Unknown Source)
>> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
>> ... 4 more
>>
>> So I tried to initialize everything by the lines:
>> PersistenceManagerFactory pmf =
>> JDOHelper.getPersistenceManagerFactory("jpox.properties");
>> PersistenceManager pm = pmf.getPersistenceManager();
>>
>> with the jpox.properties:
>> javax.jdo.PersistenceManagerFactoryClass=org.jpox.jdo.JDOPer sistenceManagerFactory
>>
>> javax.jdo.option.ConnectionDriverName=com.mysql.jdbc.Driver
>> javax.jdo.option.ConnectionURL=jdbc:mysql://127.0.0.1/emf_jpox122
>> javax.jdo.option.ConnectionUserName=root
>> javax.jdo.option.ConnectionPassword=vertrigo
>> org.jpox.autoCreateTables=true
>> org.jpox.autoCreateSchema=true
>> org.jpox.validateTables=false
>> org.jpox.validateConstraints=false
>>
>> and it starts and even creates all tables, but as soon as I create an
>> object and try to persist it with:
>> Transaction tx = pm.currentTransaction();
>> try {
>> tx.begin();
>>
>> //Create Entity
>> Entity entity = DataFactory.eINSTANCE.createEntity();
>> entity.setName("Entity");
>>
>> //Create DataModel
>> DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
>> datamodel.setName("DataModel");
>> datamodel.getEntity().add(entity);
>> //
>> pm.makePersistent(datamodel);
>>
>> tx.commit();
>>
>> } finally {
>> if(tx.isActive()) {
>> tx.rollback();
>> }
>> pm.close();
>> }
>>
>> pm.makePersistent(datamodel); throws the following exception:
>> java.lang.ClassCastException: org.jpox.sco.List cannot be cast to
>> org.eclipse.emf.common.util.EList
>> at data.impl.EntityImpl.jdoReplaceField(EntityImpl.java)
>> at
>> org.jpox.state.JDOStateManagerImpl.replaceField(JDOStateMana gerImpl.java:2546)
>>
>> at
>> org.jpox.state.JDOStateManagerImpl.replaceField(JDOStateMana gerImpl.java:2425)
>>
>> at org.jpox.sco.SCOUtils.newSCOInstance(SCOUtils.java:173)
>> at
>> org.jpox.store.mapped.mapping.AbstractContainerMapping.repla ceFieldWithWrapper(AbstractContainerMapping.java:394)
>>
>> at
>> org.jpox.store.mapped.mapping.CollectionMapping.postInsert(C ollectionMapping.java:103)
>>
>> at
>> org.jpox.store.rdbms.request.InsertRequest.execute(InsertReq uest.java:465)
>>
>> at
>> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertTable(RDB MSPersistenceHandler.java:157)
>>
>> at
>> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertObject(RD BMSPersistenceHandler.java:136)
>>
>> at
>> org.jpox.state.JDOStateManagerImpl.internalMakePersistent(JD OStateManagerImpl.java:3082)
>>
>> at
>> org.jpox.state.JDOStateManagerImpl.makePersistent(JDOStateMa nagerImpl.java:3062)
>>
>> at
>> org.jpox.ObjectManagerImpl.persistObjectInternal(ObjectManag erImpl.java:1231)
>>
>> at org.jpox.sco.SCOUtils.validateObjectForWriting(SCOUtils.java :1491)
>> at
>> org.jpox.store.rdbms.scostore.ElementContainerStore.validate ElementForWriting(ElementContainerStore.java:379)
>>
>> at
>> org.jpox.store.rdbms.scostore.FKListStore.validateElementFor Writing(FKListStore.java:1303)
>>
>> at
>> org.jpox.store.rdbms.scostore.FKListStore.internalAdd(FKList Store.java:830)
>>
>> at
>> org.jpox.store.rdbms.scostore.AbstractListStore.addAll(Abstr actListStore.java:354)
>>
>> at
>> org.jpox.store.mapped.mapping.CollectionMapping.postInsert(C ollectionMapping.java:158)
>>
>> at
>> org.jpox.store.rdbms.request.InsertRequest.execute(InsertReq uest.java:465)
>>
>> at
>> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertTable(RDB MSPersistenceHandler.java:157)
>>
>> at
>> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertObject(RD BMSPersistenceHandler.java:136)
>>
>> at
>> org.jpox.state.JDOStateManagerImpl.internalMakePersistent(JD OStateManagerImpl.java:3082)
>>
>> at
>> org.jpox.state.JDOStateManagerImpl.makePersistent(JDOStateMa nagerImpl.java:3062)
>>
>> at
>> org.jpox.ObjectManagerImpl.persistObjectInternal(ObjectManag erImpl.java:1231)
>>
>> at
>> org.jpox.ObjectManagerImpl.persistObject(ObjectManagerImpl.j ava:1077)
>> at
>> org.jpox.jdo.AbstractPersistenceManager.jdoMakePersistent(Ab stractPersistenceManager.java:666)
>>
>> at
>> org.jpox.jdo.AbstractPersistenceManager.makePersistent(Abstr actPersistenceManager.java:691)
>>
>>
>> So again the casting error.
>>
>> I hope anyone can help me with that or does know what needs to be
>> done. Again, thanks in advance.
>>
>>
>> Regards
>> Ziplies
>>
>>
>> Martin Taal wrote:
>>> Hi Ziplies,
>>> Have you tried with jpox 1.1.9? That is the version currently working
>>> with Teneo. It is clearly on my roadmap to upgrade to newer versions
>>> of jpox/datanucleus. I have not yet had time to do so.
>>>
>>> If you get exceptions/errors can you post the stacktrace? That always
>>> gives some more info.
>>>
>>> gr. Martin
>>>
>>> Savas Ziplies wrote:
>>>> Hello,
>>>>
>>>> I am currently conducting some research on how to maybe change the
>>>> software development workflow and structure in my institute. As I do
>>>> not like too suffocating solutions I thought about some modelling
>>>> approach through EMF, Teneo and DataNucleus.
>>>>
>>>> So I got myself everything needed, read all guides I could find on
>>>> eclipse.org, elver.org and datanucleus.org and started with a basic
>>>> model with basic relations. Everything worked so far as that I could
>>>> - build the model (the example model from this site
>>>> http://www.eclipse.org/gmt/oaw/doc/4.2/html/contents/emf_tut orial.html),
>>>> - create the genmodel, - generated the code and even the
>>>> - package.jdo. Everything got enhanced and then I thought I could
>>>> start persisting everything... so I thought. All the time I get the
>>>> error:
>>>> java.lang.ClassCastException: org.datanucleus.sco.List cannot be cast
>>>> to org.eclipse.emf.common.util.EList
>>>>
>>>> I looked it up, searched the newslists and forums but I couldn't figure
>>>> out the solution. I know that there is probably an error about the
>>>> implementing SCO for EList and DataNucleus, but I cannot figure out
>>>> how to tell him what to use. I found tutorials about extensions and
>>>> tried that but maybe I am just to slow for that. I do not really get
>>>> the
>>>> TypeMapping.
>>>>
>>>> The code is plain simple I think:
>>>>
>>>> PersistenceManagerFactory pmf =
>>>> JDOHelper.getPersistenceManagerFactory("datanucleus.properties ");
>>>> PersistenceManager pm = pmf.getPersistenceManager();
>>>>
>>>> Transaction tx = pm.currentTransaction();
>>>> try {
>>>> tx.begin();
>>>>
>>>> //
>>>> DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
>>>> datamodel.setName("DataModel");
>>>>
>>>> //
>>>> pm.makePersistent(datamodel);
>>>>
>>>> tx.commit();
>>>>
>>>> } finally {
>>>> if(tx.isActive()) {
>>>> tx.rollback();
>>>> }
>>>> pm.close();
>>>> }
>>>>
>>>> The tables are created in the database (a test MySQL DB). But
>>>> pm.makePersistent(datamodel); kicks him out with the exception.
>>>>
>>>> I tried the creation with
>>>>
>>>> JpoxDataStore jpoxDataStore =
>>>> JpoxHelper.INSTANCE.createRegisterDataStore("Data");
>>>>
>>>> but that throws errors from the beginning, as I think maybe something
>>>> changed from Jpox to DataNucleus. So I tried older versions, before
>>>> DataNucleus, so with Jpox directly, then the
>>>> jpoxDataStore.initialize(); keeps getting errors.
>>>>
>>>> As you can see I am very desperate at the moment and I hope anyone
>>>> can help me.
>>>>
>>>> Many many thanks in advance and thanks for every response.
>>>>
>>>>
>>>> Regards
>>>> Ziplies
>>>>
>>>>
>>>> PS: I am using Eclipse 3.4M7 (but I have different installations
>>>> with different plugins running, for testing purposes), EMF
>>>> 2.4.0v200805052017 and Teneo 0.8.0v200804231747 with DataNucleus
>>>> 1.0.0m1.
>>>>
>>>> The ecore model is following, the rest is generated through the
>>>> described plugins
>>>> plus my Test Class up above:
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <ecore:EPackage xmi:version="2.0"
>>>> xmlns:xmi="http://www.omg.org/XMI"
>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="data"
>>>>
>>>> nsURI="http://www.openarchitectureware.org/oaw4.demo.emf.datamodel"
>>>> nsPrefix="data">
>>>> <eClassifiers xsi:type="ecore:EClass" name="DataModel">
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>>> eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>> <eStructuralFeatures xsi:type="ecore:EReference" name="entity"
>>>> upperBound="-1"
>>>> eType="#//Entity" containment="true"/>
>>>> </eClassifiers>
>>>> <eClassifiers xsi:type="ecore:EClass" name="Entity">
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>>> eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>> <eStructuralFeatures xsi:type="ecore:EReference" name="attribute"
>>>> lowerBound="1"
>>>> upperBound="-1" eType="#//Attribute" containment="true"/>
>>>> <eStructuralFeatures xsi:type="ecore:EReference" name="reference"
>>>> upperBound="-1"
>>>> eType="#//EntityReference" containment="true"/>
>>>> </eClassifiers>
>>>> <eClassifiers xsi:type="ecore:EClass" name="Attribute">
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>>> eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
>>>> eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>> </eClassifiers>
>>>> <eClassifiers xsi:type="ecore:EClass" name="EntityReference">
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>>> eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="toMany"
>>>> eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
>>>> <eStructuralFeatures xsi:type="ecore:EReference" name="target"
>>>> lowerBound="1"
>>>> eType="#//Entity"/>
>>>> </eClassifiers>
>>>> </ecore:EPackage>
>>>
>>>
>
>
Re: ClassCastException to EList [message #618111 is a reply to message #122795] Wed, 21 May 2008 20:06 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Ziplies,
I didn't see an offense. I think you read more in my reply then I wrote into it/or ment to write
into it. With be patient (if that is what you reacted on) I mean that it will take me some time to
do this. More time than I like, but it is a fair amount of work getting 40 or so testcases back on
their feet.

If more people ask for the jpox upgrade the quicker it will happen so your post pointing out the
issues you are having is right on the spot and perfectly fine.

gr. Martin

Savas Ziplies wrote:
> Hi,
>
> that was meant with no offense or something. I am maintaning myself
> several projects and I understand you more than you might think.
>
> So, keep up the good work and sometime we'll see what we need. Thx!
>
> Regards
>
>
> Martin Taal wrote:
>> Hi Ziplies,
>> Jpox has made a lot of internal api changes going from 1.1.9 to 1.2. I
>> have not yet had the time to upgrade Teneo to jpox 1.2 (as Teneo uses
>> the internal jpox api). This is a fair amount of work which I need to
>> look at in more detail. Also I was a bit reluctant because going to
>> jpox 1.2 means that all current jpox-teneo users also needed to
>> upgrade to 1.2. I don't have the capacity to maintain multiple Teneo
>> branches for different versions of jpox.
>> Teneo-Jpox has about 85 testcases which are run in 2 scenarios. If I
>> run these testcases on jpox 1.2 then about half will fail. So before
>> it makes sense for you to test it I would first need to get all the
>> testcases to pass...
>>
>> The only thing you can do at the moment is be patient and add your
>> name to the bugzilla for this to get an update on what happens:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=195434
>>
>> gr. Martin
>>
>> Savas Ziplies wrote:
>>> Hi,
>>>
>>> so after I always tested with Jpox1.2.2 or DataNucleus1.0.0m1 I got
>>> it to work with Jpox1.1.9, like you proposed. First of all thanks for
>>> that!
>>> Now I got Eclipse3.3.2 running with EMF2.3.2, Teneo I0.8.0 and
>>> Jpox1.1.9.
>>> But, I was eager to know why since Jpox1.2.0 it is not running
>>> anymore, because from Version 1.2 beginning I get different errors,
>>> and maybe you can help to fix them or can use them as BugReports.
>>>
>>> So, the same configuration (Eclipse3.3.2 running with EMF2.3.2, Teneo
>>> I0.8.0) with Jpox1.2.0 gives me two differnt errors on different
>>> approaches. First:
>>> If I try to initialize in 1.2.0 with
>>> //
>>> Properties properties = new Properties();
>>> properties.setProperty("javax.jdo.option.ConnectionDriverName ",
>>> "com.mysql.jdbc.Driver");
>>> properties.setProperty("javax.jdo.option.ConnectionURL",
>>> "jdbc:mysql://127.0.0.1:3306/emf_jpox122");
>>> properties.setProperty("javax.jdo.option.ConnectionUserName ", "root");
>>> properties.setProperty("javax.jdo.option.ConnectionPassword ",
>>> "vertrigo");
>>>
>>> //
>>> String pmfName = "emf"; // the name of the JpoxDataStore
>>> JpoxDataStore jpoxDataStore =
>>> JpoxHelper.INSTANCE.createRegisterDataStore(pmfName);
>>> jpoxDataStore.setProperties(properties);
>>> jpoxDataStore.setEPackages(new EPackage[]{DataPackage.eINSTANCE});
>>> jpoxDataStore.initialize();
>>>
>>> the line jpoxDataStore.initialize(); is throwing the following
>>> exception:
>>> Exception in thread "main" java.lang.NoClassDefFoundError:
>>> org/jpox/AbstractPersistenceManagerFactory
>>> at
>>> org.eclipse.emf.teneo.jpox.JpoxDataStore.createSchema(JpoxDa taStore.java:536)
>>>
>>> at
>>> org.eclipse.emf.teneo.jpox.JpoxDataStore.initialize(JpoxData Store.java:228)
>>>
>>> at Run.<init>(Run.java:64)
>>> at Run.main(Run.java:30)
>>> Caused by: java.lang.ClassNotFoundException:
>>> org.jpox.AbstractPersistenceManagerFactory
>>> at java.net.URLClassLoader$1.run(Unknown Source)
>>> at java.security.AccessController.doPrivileged(Native Method)
>>> at java.net.URLClassLoader.findClass(Unknown Source)
>>> at java.lang.ClassLoader.loadClass(Unknown Source)
>>> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>>> at java.lang.ClassLoader.loadClass(Unknown Source)
>>> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
>>> ... 4 more
>>>
>>> So I tried to initialize everything by the lines:
>>> PersistenceManagerFactory pmf =
>>> JDOHelper.getPersistenceManagerFactory("jpox.properties");
>>> PersistenceManager pm = pmf.getPersistenceManager();
>>>
>>> with the jpox.properties:
>>> javax.jdo.PersistenceManagerFactoryClass=org.jpox.jdo.JDOPer sistenceManagerFactory
>>>
>>> javax.jdo.option.ConnectionDriverName=com.mysql.jdbc.Driver
>>> javax.jdo.option.ConnectionURL=jdbc:mysql://127.0.0.1/emf_jpox122
>>> javax.jdo.option.ConnectionUserName=root
>>> javax.jdo.option.ConnectionPassword=vertrigo
>>> org.jpox.autoCreateTables=true
>>> org.jpox.autoCreateSchema=true
>>> org.jpox.validateTables=false
>>> org.jpox.validateConstraints=false
>>>
>>> and it starts and even creates all tables, but as soon as I create an
>>> object and try to persist it with:
>>> Transaction tx = pm.currentTransaction();
>>> try {
>>> tx.begin();
>>>
>>> //Create Entity
>>> Entity entity = DataFactory.eINSTANCE.createEntity();
>>> entity.setName("Entity");
>>>
>>> //Create DataModel
>>> DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
>>> datamodel.setName("DataModel");
>>> datamodel.getEntity().add(entity);
>>> //
>>> pm.makePersistent(datamodel);
>>>
>>> tx.commit();
>>>
>>> } finally {
>>> if(tx.isActive()) {
>>> tx.rollback();
>>> }
>>> pm.close();
>>> }
>>>
>>> pm.makePersistent(datamodel); throws the following exception:
>>> java.lang.ClassCastException: org.jpox.sco.List cannot be cast to
>>> org.eclipse.emf.common.util.EList
>>> at data.impl.EntityImpl.jdoReplaceField(EntityImpl.java)
>>> at
>>> org.jpox.state.JDOStateManagerImpl.replaceField(JDOStateMana gerImpl.java:2546)
>>>
>>> at
>>> org.jpox.state.JDOStateManagerImpl.replaceField(JDOStateMana gerImpl.java:2425)
>>>
>>> at org.jpox.sco.SCOUtils.newSCOInstance(SCOUtils.java:173)
>>> at
>>> org.jpox.store.mapped.mapping.AbstractContainerMapping.repla ceFieldWithWrapper(AbstractContainerMapping.java:394)
>>>
>>> at
>>> org.jpox.store.mapped.mapping.CollectionMapping.postInsert(C ollectionMapping.java:103)
>>>
>>> at
>>> org.jpox.store.rdbms.request.InsertRequest.execute(InsertReq uest.java:465)
>>>
>>> at
>>> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertTable(RDB MSPersistenceHandler.java:157)
>>>
>>> at
>>> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertObject(RD BMSPersistenceHandler.java:136)
>>>
>>> at
>>> org.jpox.state.JDOStateManagerImpl.internalMakePersistent(JD OStateManagerImpl.java:3082)
>>>
>>> at
>>> org.jpox.state.JDOStateManagerImpl.makePersistent(JDOStateMa nagerImpl.java:3062)
>>>
>>> at
>>> org.jpox.ObjectManagerImpl.persistObjectInternal(ObjectManag erImpl.java:1231)
>>>
>>> at
>>> org.jpox.sco.SCOUtils.validateObjectForWriting(SCOUtils.java :1491)
>>> at
>>> org.jpox.store.rdbms.scostore.ElementContainerStore.validate ElementForWriting(ElementContainerStore.java:379)
>>>
>>> at
>>> org.jpox.store.rdbms.scostore.FKListStore.validateElementFor Writing(FKListStore.java:1303)
>>>
>>> at
>>> org.jpox.store.rdbms.scostore.FKListStore.internalAdd(FKList Store.java:830)
>>>
>>> at
>>> org.jpox.store.rdbms.scostore.AbstractListStore.addAll(Abstr actListStore.java:354)
>>>
>>> at
>>> org.jpox.store.mapped.mapping.CollectionMapping.postInsert(C ollectionMapping.java:158)
>>>
>>> at
>>> org.jpox.store.rdbms.request.InsertRequest.execute(InsertReq uest.java:465)
>>>
>>> at
>>> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertTable(RDB MSPersistenceHandler.java:157)
>>>
>>> at
>>> org.jpox.store.rdbms.RDBMSPersistenceHandler.insertObject(RD BMSPersistenceHandler.java:136)
>>>
>>> at
>>> org.jpox.state.JDOStateManagerImpl.internalMakePersistent(JD OStateManagerImpl.java:3082)
>>>
>>> at
>>> org.jpox.state.JDOStateManagerImpl.makePersistent(JDOStateMa nagerImpl.java:3062)
>>>
>>> at
>>> org.jpox.ObjectManagerImpl.persistObjectInternal(ObjectManag erImpl.java:1231)
>>>
>>> at
>>> org.jpox.ObjectManagerImpl.persistObject(ObjectManagerImpl.j ava:1077)
>>> at
>>> org.jpox.jdo.AbstractPersistenceManager.jdoMakePersistent(Ab stractPersistenceManager.java:666)
>>>
>>> at
>>> org.jpox.jdo.AbstractPersistenceManager.makePersistent(Abstr actPersistenceManager.java:691)
>>>
>>>
>>> So again the casting error.
>>>
>>> I hope anyone can help me with that or does know what needs to be
>>> done. Again, thanks in advance.
>>>
>>>
>>> Regards
>>> Ziplies
>>>
>>>
>>> Martin Taal wrote:
>>>> Hi Ziplies,
>>>> Have you tried with jpox 1.1.9? That is the version currently
>>>> working with Teneo. It is clearly on my roadmap to upgrade to newer
>>>> versions of jpox/datanucleus. I have not yet had time to do so.
>>>>
>>>> If you get exceptions/errors can you post the stacktrace? That
>>>> always gives some more info.
>>>>
>>>> gr. Martin
>>>>
>>>> Savas Ziplies wrote:
>>>>> Hello,
>>>>>
>>>>> I am currently conducting some research on how to maybe change the
>>>>> software development workflow and structure in my institute. As I do
>>>>> not like too suffocating solutions I thought about some modelling
>>>>> approach through EMF, Teneo and DataNucleus.
>>>>>
>>>>> So I got myself everything needed, read all guides I could find on
>>>>> eclipse.org, elver.org and datanucleus.org and started with a basic
>>>>> model with basic relations. Everything worked so far as that I could
>>>>> - build the model (the example model from this site
>>>>> http://www.eclipse.org/gmt/oaw/doc/4.2/html/contents/emf_tut orial.html),
>>>>> - create the genmodel, - generated the code and even the
>>>>> - package.jdo. Everything got enhanced and then I thought I could
>>>>> start persisting everything... so I thought. All the time I get the
>>>>> error:
>>>>> java.lang.ClassCastException: org.datanucleus.sco.List cannot be cast
>>>>> to org.eclipse.emf.common.util.EList
>>>>>
>>>>> I looked it up, searched the newslists and forums but I couldn't
>>>>> figure
>>>>> out the solution. I know that there is probably an error about the
>>>>> implementing SCO for EList and DataNucleus, but I cannot figure out
>>>>> how to tell him what to use. I found tutorials about extensions and
>>>>> tried that but maybe I am just to slow for that. I do not really
>>>>> get the
>>>>> TypeMapping.
>>>>>
>>>>> The code is plain simple I think:
>>>>>
>>>>> PersistenceManagerFactory pmf =
>>>>> JDOHelper.getPersistenceManagerFactory("datanucleus.properties ");
>>>>> PersistenceManager pm = pmf.getPersistenceManager();
>>>>>
>>>>> Transaction tx = pm.currentTransaction();
>>>>> try {
>>>>> tx.begin();
>>>>>
>>>>> //
>>>>> DataModel datamodel = DataFactory.eINSTANCE.createDataModel();
>>>>> datamodel.setName("DataModel");
>>>>>
>>>>> //
>>>>> pm.makePersistent(datamodel);
>>>>>
>>>>> tx.commit();
>>>>>
>>>>> } finally {
>>>>> if(tx.isActive()) {
>>>>> tx.rollback();
>>>>> }
>>>>> pm.close();
>>>>> }
>>>>>
>>>>> The tables are created in the database (a test MySQL DB). But
>>>>> pm.makePersistent(datamodel); kicks him out with the exception.
>>>>>
>>>>> I tried the creation with
>>>>>
>>>>> JpoxDataStore jpoxDataStore =
>>>>> JpoxHelper.INSTANCE.createRegisterDataStore("Data");
>>>>>
>>>>> but that throws errors from the beginning, as I think maybe something
>>>>> changed from Jpox to DataNucleus. So I tried older versions, before
>>>>> DataNucleus, so with Jpox directly, then the
>>>>> jpoxDataStore.initialize(); keeps getting errors.
>>>>>
>>>>> As you can see I am very desperate at the moment and I hope anyone
>>>>> can help me.
>>>>>
>>>>> Many many thanks in advance and thanks for every response.
>>>>>
>>>>>
>>>>> Regards
>>>>> Ziplies
>>>>>
>>>>>
>>>>> PS: I am using Eclipse 3.4M7 (but I have different installations
>>>>> with different plugins running, for testing purposes), EMF
>>>>> 2.4.0v200805052017 and Teneo 0.8.0v200804231747 with DataNucleus
>>>>> 1.0.0m1.
>>>>>
>>>>> The ecore model is following, the rest is generated through the
>>>>> described plugins
>>>>> plus my Test Class up above:
>>>>>
>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>> <ecore:EPackage xmi:version="2.0"
>>>>> xmlns:xmi="http://www.omg.org/XMI"
>>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="data"
>>>>>
>>>>> nsURI="http://www.openarchitectureware.org/oaw4.demo.emf.datamodel"
>>>>> nsPrefix="data">
>>>>> <eClassifiers xsi:type="ecore:EClass" name="DataModel">
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>>>> eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>> <eStructuralFeatures xsi:type="ecore:EReference" name="entity"
>>>>> upperBound="-1"
>>>>> eType="#//Entity" containment="true"/>
>>>>> </eClassifiers>
>>>>> <eClassifiers xsi:type="ecore:EClass" name="Entity">
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>>>> eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>> <eStructuralFeatures xsi:type="ecore:EReference"
>>>>> name="attribute" lowerBound="1"
>>>>> upperBound="-1" eType="#//Attribute" containment="true"/>
>>>>> <eStructuralFeatures xsi:type="ecore:EReference"
>>>>> name="reference" upperBound="-1"
>>>>> eType="#//EntityReference" containment="true"/>
>>>>> </eClassifiers>
>>>>> <eClassifiers xsi:type="ecore:EClass" name="Attribute">
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>>>> eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
>>>>> eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>> </eClassifiers>
>>>>> <eClassifiers xsi:type="ecore:EClass" name="EntityReference">
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>>>> eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="toMany"
>>>>> eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
>>>>> <eStructuralFeatures xsi:type="ecore:EReference" name="target"
>>>>> lowerBound="1"
>>>>> eType="#//Entity"/>
>>>>> </eClassifiers>
>>>>> </ecore:EPackage>
>>>>
>>>>
>>
>>


--

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
Previous Topic:[EMF Compare] How to use EMF Compare in Java
Next Topic:[CDO 0.8.0] EMap
Goto Forum:
  


Current Time: Thu Apr 18 08:07:58 GMT 2024

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

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

Back to the top