Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] References across two EMF models
[CDO] References across two EMF models [message #726835] Mon, 19 September 2011 16:34 Go to next message
Slawomir Duszynski is currently offline Slawomir DuszynskiFriend
Messages: 7
Registered: July 2011
Junior Member
Hi,

I am working with CDO/Teneo/EMF since some time and so far persisting of my Model1 worked well. Now, I need to persist a Model2 in the same CDO resource - and it also works correctly, but only if there are no references between Model1 and Model2.

Now, I need a ClassY from Model2 to reference ClassX from Model1 (no containment). I added an appropriate reference to ClassY, regenerated the model classes, and ran the same code that worked previously (basically, Model2 package is registered, a single ClassY object is created and added to the resource contents, some ClassX objects already exist in the repository). However, when I commit the transaction I get:

org.eclipse.emf.cdo.util.CommitException: java.lang.NullPointerException
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1072)
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1078)
at de.fhg.iese.cdo.camos.tasks.AbstractTask.commit(AbstractTask.java:124)
at de.fhg.iese.cdo.camos.tasks.AbstractTask.closeTransaction(AbstractTask.java:68)
at de.fhg.iese.cdo.camos.tasks.TransformTask.processData(TransformTask.java:67)
at de.fhg.iese.cdo.camos.tasks.TransformTask.executeTaskSpecific(TransformTask.java:23)
at de.fhg.iese.cdo.camos.tasks.AbstractTask.executeTask(AbstractTask.java:36)
at de.fhg.iese.cdo.camos.TestClient.main(TestClient.java:24)
Caused by: java.lang.NullPointerException
at org.eclipse.emf.cdo.common.model.CDOModelUtil.isTypesPackage(CDOModelUtil.java:166)
at org.eclipse.emf.cdo.common.model.CDOModelUtil.isLob(CDOModelUtil.java:182)
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl$CDOCommitContextImpl.collectLobs(CDOTransactionImpl.java:2582)
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl$CDOCommitContextImpl.preCommit(CDOTransactionImpl.java:2570)
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl$CDOCommitContextImpl.preCommit(CDOTransactionImpl.java:2414)
at org.eclipse.emf.internal.cdo.transaction.CDOSingleTransactionStrategyImpl.commit(CDOSingleTransactionStrategyImpl.java:66)
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1058)
... 7 more

After debugging, I saw that this happens when the CDO code in CDOModelUtil.isLob analyzes the newly added reference from ClassY to ClassX. Basically, all the properties of eClassifier representing the reference in CDOModelUtil.isLob are null. Any ideas why the reference info wasn't resolved? Should I configure something in the EMF of the reference?

Thanks,
Slawomir
Re: [CDO] References across two EMF models [message #726962 is a reply to message #726835] Tue, 20 September 2011 04:28 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Slawomir,

As you've found out the CDOTransactionImpl.CDOCommitContextImpl.collectLobs() makes a call to
CDOModelUtil.isLob(feature.getEType()). From the stack trace it seems that the feature of your model has an EClassifer
as type that does not belong to an EPackage. To me it looks like a problem with your meta model. What is this feature
and what is its EType?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Am 19.09.2011 18:34, schrieb Slawomir Duszynski:
> Hi,
>
> I am working with CDO/Teneo/EMF since some time and so far persisting of my Model1 worked well. Now, I need to persist
> a Model2 in the same CDO resource - and it also works correctly, but only if there are no references between Model1
> and Model2.
>
> Now, I need a ClassY from Model2 to reference ClassX from Model1 (no containment). I added an appropriate reference to
> ClassY, regenerated the model classes, and ran the same code that worked previously (basically, Model2 package is
> registered, a single ClassY object is created and added to the resource contents, some ClassX objects already exist in
> the repository). However, when I commit the transaction I get:
>
> org.eclipse.emf.cdo.util.CommitException: java.lang.NullPointerException
> at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1072)
> at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1078)
> at de.fhg.iese.cdo.camos.tasks.AbstractTask.commit(AbstractTask.java:124)
> at de.fhg.iese.cdo.camos.tasks.AbstractTask.closeTransaction(AbstractTask.java:68)
> at de.fhg.iese.cdo.camos.tasks.TransformTask.processData(TransformTask.java:67)
> at de.fhg.iese.cdo.camos.tasks.TransformTask.executeTaskSpecific(TransformTask.java:23)
> at de.fhg.iese.cdo.camos.tasks.AbstractTask.executeTask(AbstractTask.java:36)
> at de.fhg.iese.cdo.camos.TestClient.main(TestClient.java:24)
> Caused by: java.lang.NullPointerException
> at org.eclipse.emf.cdo.common.model.CDOModelUtil.isTypesPackage(CDOModelUtil.java:166)
> at org.eclipse.emf.cdo.common.model.CDOModelUtil.isLob(CDOModelUtil.java:182)
> at
> org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl$CDOCommitContextImpl.collectLobs(CDOTransactionImpl.java:2582)
> at
> org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl$CDOCommitContextImpl.preCommit(CDOTransactionImpl.java:2570)
> at
> org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl$CDOCommitContextImpl.preCommit(CDOTransactionImpl.java:2414)
> at
> org.eclipse.emf.internal.cdo.transaction.CDOSingleTransactionStrategyImpl.commit(CDOSingleTransactionStrategyImpl.java:66)
> at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1058)
> ... 7 more
>
> After debugging, I saw that this happens when the CDO code in CDOModelUtil.isLob analyzes the newly added reference
> from ClassY to ClassX. Basically, all the properties of eClassifier representing the reference in CDOModelUtil.isLob
> are null. Any ideas why the reference info wasn't resolved? Should I configure something in the EMF of the reference?
>
> Thanks,
> Slawomir


Re: [CDO] References across two EMF models [message #726966 is a reply to message #726962] Tue, 20 September 2011 05:13 Go to previous messageGo to next message
Slawomir Duszynski is currently offline Slawomir DuszynskiFriend
Messages: 7
Registered: July 2011
Junior Member
Hi Eike,

yes, exactly, the problem occurs for a EFeature which is a EReference to the other model - it is a feature of ClassY(Model2) and its EType is ClassX(Model1).

<eClassifiers xsi:type="ecore:EClass" name="ClassY">
<eStructuralFeatures xsi:type="ecore:EReference" name="source" upperBound="-1"
eType="ecore:EClass ../../Model1/model/Model1.ecore#//ClassX">
</eStructuralFeatures>
</eClassifiers>


Cheers,
Slawomir
Re: [CDO] References across two EMF models [message #727002 is a reply to message #726966] Tue, 20 September 2011 06:43 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 20.09.2011 07:13, schrieb Slawomir Duszynski:
> Hi Eike,
>
> yes, exactly, the problem occurs for a EFeature which is a EReference to the other model - it is a feature of
> ClassY(Model2) and its EType is ClassX(Model1).
>
> <eClassifiers xsi:type="ecore:EClass" name="ClassY">
> <eStructuralFeatures xsi:type="ecore:EReference" name="source" upperBound="-1"
> eType="ecore:EClass ../../Model1/model/Model1.ecore#//ClassX">
> </eStructuralFeatures>
> </eClassifiers>
At runtime, are you using these models dynamically? Are you loading them from your file system?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] References across two EMF models [message #727250 is a reply to message #727002] Tue, 20 September 2011 17:37 Go to previous messageGo to next message
Slawomir Duszynski is currently offline Slawomir DuszynskiFriend
Messages: 7
Registered: July 2011
Junior Member
No, the models are statically known to my CDO client plugin. The MANIFEST.MF references both model plugins as Require-Bundle, when starting the client I register the packages

CDOSession session = sessionConfiguration.openSession();

org.eclipse.emf.cdo.net4j.CDOSession.Options sessionOptions = (org.eclipse.emf.cdo.net4j.CDOSession.Options) session
.options();
sessionOptions.getProtocol().setTimeout(ISignalProtocol.NO_TIMEOUT);
System.out.println(session + " open");

// package registry
session.getPackageRegistry().putEPackage(Model1Package.eINSTANCE);
System.out.println(Model1Package.eNAME + " put in registry");

session.getPackageRegistry().putEPackage(Model2Package.eINSTANCE);
System.out.println(Model2Package.eNAME + " put in registry");


and then I just create various objects and add them to the CDOResource:


ClassY info = Model2Factory.eINSTANCE.createClassY();
CDOResource res = transaction.getOrCreateResource(resourceName);
res.getContents().add(info);


As I said, everything works ok as long as EMF of Model2 contains no references to Model1. But as soon as I add such a reference to ClassY, it is not possible to commit ClassY object to the repository. I debugged more, changing different EMF properties and project settings, but nothing helped so far.

Are there any tutorials/documentation/examples on how to handle a case of two referencing models with CDO and Teneo? I suppose something is wrong with my configuration, maybe I could figure it out looking at a working reference case.

Cheers,
Slawomir
Re: [CDO] References across two EMF models [message #727451 is a reply to message #727250] Wed, 21 September 2011 10:45 Go to previous messageGo to next message
Slawomir Duszynski is currently offline Slawomir DuszynskiFriend
Messages: 7
Registered: July 2011
Junior Member
Hi again,

I constructed a simple reference case of two related EMF models and the CDO/Teneo persistence worked right away without any magic. The original model where the problem occurred is still not working though. Since I have a working example now, I will figure out myself what might have went wrong there and will let you know.

Thanks for help anyway!

Best regards,
Slawomir
Re: [CDO] References across two EMF models [message #727582 is a reply to message #727451] Wed, 21 September 2011 15:05 Go to previous messageGo to next message
Slawomir Duszynski is currently offline Slawomir DuszynskiFriend
Messages: 7
Registered: July 2011
Junior Member
Problem solved - although the solution is "magic", that is I do not know why it works. My model was created from an XSD file, and as Namespace URI the generator has written by default

platform:/resource/Model1/model/Model1.xsd,

which was the file the model was created from. When I changed the NS URI to

http://Model1/model/Model1.ecore

the problem disappeared and now both models can be serialized correctly.

Best,
Slawomir
Re: [CDO] References across two EMF models [message #727583 is a reply to message #727582] Wed, 21 September 2011 15:11 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 21.09.2011 17:05, schrieb Slawomir Duszynski:
> Problem solved - although the solution is "magic", that is I do not know why it works. My model was created from an
> XSD file, and as Namespace URI the generator has written by default
>
> platform:/resource/Model1/model/Model1.xsd,
> which was the file the model was created from. When I changed the NS URI to
> http://Model1/model/Model1.ecore
>
> the problem disappeared and now both models can be serialized correctly.
I'm glad that you could solve it ;-)

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Previous Topic:[CDO] Launching server programmatically
Next Topic:[CDO] Configure Failover via cdo-server.xml?
Goto Forum:
  


Current Time: Fri Apr 26 21:02:21 GMT 2024

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

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

Back to the top