Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] "Different object was registered for OID XX" in Native mode
[CDO] "Different object was registered for OID XX" in Native mode [message #902825] Mon, 20 August 2012 11:57 Go to next message
Alex Lagarde is currently offline Alex Lagarde
Messages: 177
Registered: May 2010
Senior Member

Hi everyone,

I'm facing the "different object was registered for OID XX" issue with CDO, although I think my use case is legit.

My Repository contains :
- a CDOResource A containing a root r1
- a CDOResource B containing a root r2 referencing r1
Both r1 and r2 are in CDONative mode (no Legacy here).

When I load r2 and get its lists of referenced elements,
this calls AbstractCDOView.getObject(r1's CDOID)
which creates a new Java instance for r1 as it is not in the 'objects' map of my transaction yet.

When creating r1 (inside createObject(r1's CDOID)), we call the cleanObject() method before putting r1 in the 'objects' map.
This clean Object bethods, by setting the state of R1 to CLEAN, notifies the CleanObjectHandler, which asks for r1's CDOResource (by a call to isContained()):
	CDOStoreImpl.getResource(InternalEObject) line: 163	
	R1Impl(CDOObjectImpl).eDirectResource() line: 456	
	R1Impl(BasicEObjectImpl).eInternalResource() line: 931	
	R1Impl(CDOObjectImpl).eInternalResource() line: 467	
	R1Impl(BasicEObjectImpl).eResource() line: 926	
	R1Impl(CDOObjectImpl).cdoResource() line: 127	
	R1Impl(CDOObjectImpl).cdoResource() line: 1	
	CDOModificationTrackingAdapter(CDOLazyContentAdapter).isContained(CDOObject) line: 212	
	CDOLazyContentAdapter.access$2(CDOLazyContentAdapter, CDOObject) line: 197	
	CDOLazyContentAdapter$CleanObjectHandler.objectStateChanged(CDOView, CDOObject, CDOState, CDOState) line: 227	
	CDOTransactionImpl(AbstractCDOView).handleObjectStateChanged(InternalCDOObject, CDOState, CDOState) line: 967	
	R1Impl(CDOObjectImpl).cdoInternalSetState(CDOState) line: 228	
	CDOTransactionImpl(AbstractCDOView).cleanObject(InternalCDOObject, InternalCDORevision) line: 746	
	CDOTransactionImpl(AbstractCDOView).createObject(CDOID) line: 691	
	CDOTransactionImpl(AbstractCDOView).getObject(CDOID, boolean) line: 605	


The problem is that, when loading r1's CDOResource, we try to install ContentAdapters on this CDOResource and its children, including r1. At this moment, when trying to get r1 from the 'objects' map, as we have not put it on the map yet it's created twice:
	CDOTransactionImpl(AbstractCDOView).newInstance(EClass) line: 553	
	CDOTransactionImpl(AbstractCDOView).createObject(CDOID) line: 687	
	CDOTransactionImpl(AbstractCDOView).getObject(CDOID, boolean) line: 605	
	CDOTransactionImpl.getObject(CDOID, boolean) line: 885	
	CDOTransactionImpl(AbstractCDOView).convertIDToObject(Object) line: 860	
	CDOStoreImpl.convertIDToObject(InternalCDOView, EObject, EStructuralFeature, int, Object) line: 668	
	CDOStoreImpl.convertToEMF(EObject, InternalCDORevision, EStructuralFeature, int, Object) line: 636	
	CDOStoreImpl.get(InternalEObject, EStructuralFeature, int) line: 187		CDOResourceImpl$ContentsCDOList(EStoreEObjectImpl$BasicEStoreEList<E>).delegateGet(int) line: 247	
	CDOResourceImpl$ContentsCDOList(DelegatingEList<E>).primitiveGet(int) line: 267	
	AbstractEList$NonResolvingEListIterator<E1>.doNext() line: 1063	
	AbstractEList$NonResolvingEListIterator<E1>(AbstractEList$EIterator<E1>).next() line: 696	
	EContentsEList$FeatureIteratorImpl<E>.hasNext() line: 443	
	TransactionChangeRecorder.setTarget(Notifier) line: 155	
	CDOObjectImpl$1(BasicNotifierImpl$EAdapterList<E>).didAdd(int, E) line: 127	
	CDOObjectImpl$1.didAdd(int, Adapter) line: 419	
	CDOObjectImpl$1.didAdd(int, Object) line: 1	
	CDOObjectImpl$1(BasicEList<E>).addUnique(E) line: 425	
	CDOObjectImpl$1(AbstractEList<E>).add(E) line: 307	
	CDOObjectImpl$1(BasicNotifierImpl$EAdapterList<E>).add(E) line: 199	
	ChangeRecorder.addAdapter(Notifier) line: 631	
	ChangeRecorder.notifyChanged(Notification) line: 285		
	ResourceSetImpl(BasicNotifierImpl).eNotify(Notification) line: 380		ResourceSetImpl$ResourcesEList<E>(NotifyingListImpl<E>).dispatchNotification(Notification) line: 267	
	ResourceSetImpl$ResourcesEList<E>(NotifyingListImpl<E>).addUnique(E) line: 300	
	ResourceSetImpl$ResourcesEList<E>(AbstractEList<E>).add(E) line: 307	
	ResourceSetImpl.createResource(URI, String) line: 426	
	ResourceSetImpl.demandCreateResource(URI) line: 239	
	ResourceSetImpl.getResource(URI, boolean) line: 391	
	CDOTransactionImpl(AbstractCDOView).getResource(String, boolean) line: 416	
	CDOTransactionImpl(AbstractCDOView).newResourceInstance(InternalCDORevision) line: 711	


This creation is successfull, and this new r1 instance is put in the objects map.

Later, when trying to put the r1 we created at the beginning in the objects map, we realize that it has already been created, so we throw an illegal state exception.


I just tested a solution in which, inside the cleanObject() method, we do not set the CDOState to CLEAN. This should be done later, once the object has been put to the 'objects' map (actually just after the registerObject() call). It seems to work, but I'll have to determine the impacts of such a fix.

Am I missing something where that could explain my issue?
Do anyone see the possible impacts of the proposed fix?

Best Regards,
Alex
Re: [CDO] &quot;Different object was registered for OID XX&quot; in Native mode [message #902913 is a reply to message #902825] Tue, 21 August 2012 02:46 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5502
Registered: July 2009
Senior Member
Hi Alex,

I could imagine to move some calls around to make the state handler being notified when the object in question is
regeistered with the objects map. Today I'm totally busy with release engineering for Juno SR1 and Kepler M1. In the
meantime, can you please submit a bugzilla and attach a test case that demos your problem? Please extend Abstract
CDOTest and use the test models we provide. Thanks ;-)

Cheers
/Eike

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


Am 20.08.2012 17:57, schrieb Alex Lagarde:
> Hi everyone,
>
> I'm facing the "different object was registered for OID XX" issue with CDO, although I think my use case is legit.
>
> My Repository contains : - a CDOResource A containing a root r1
> - a CDOResource B containing a root r2 referencing r1
> Both r1 and r2 are in CDONative mode (no Legacy here).
>
> When I load r2 and get its lists of referenced elements,
> this calls AbstractCDOView.getObject(r1's CDOID)
> which creates a new Java instance for r1 as it is not in the 'objects' map of my transaction yet.
>
> When creating r1 (inside createObject(r1's CDOID)), we call the cleanObject() method before putting r1 in the
> 'objects' map.
> This clean Object bethods, by setting the state of R1 to CLEAN, notifies the CleanObjectHandler, which asks for r1's
> CDOResource (by a call to isContained()):
>
> CDOStoreImpl.getResource(InternalEObject) line: 163
> R1Impl(CDOObjectImpl).eDirectResource() line: 456
> R1Impl(BasicEObjectImpl).eInternalResource() line: 931
> R1Impl(CDOObjectImpl).eInternalResource() line: 467
> R1Impl(BasicEObjectImpl).eResource() line: 926
> R1Impl(CDOObjectImpl).cdoResource() line: 127
> R1Impl(CDOObjectImpl).cdoResource() line: 1
> CDOModificationTrackingAdapter(CDOLazyContentAdapter).isContained(CDOObject) line: 212
> CDOLazyContentAdapter.access$2(CDOLazyContentAdapter, CDOObject) line: 197
> CDOLazyContentAdapter$CleanObjectHandler.objectStateChanged(CDOView, CDOObject, CDOState, CDOState) line: 227
> CDOTransactionImpl(AbstractCDOView).handleObjectStateChanged(InternalCDOObject, CDOState, CDOState) line: 967
> R1Impl(CDOObjectImpl).cdoInternalSetState(CDOState) line: 228
> CDOTransactionImpl(AbstractCDOView).cleanObject(InternalCDOObject, InternalCDORevision) line: 746
> CDOTransactionImpl(AbstractCDOView).createObject(CDOID) line: 691
> CDOTransactionImpl(AbstractCDOView).getObject(CDOID, boolean) line: 605
>
>
> The problem is that, when loading r1's CDOResource, we try to install ContentAdapters on this CDOResource and its
> children, including r1. At this moment, when trying to get r1 from the 'objects' map, as we have not put it on the
> map yet it's created twice:
> CDOTransactionImpl(AbstractCDOView).newInstance(EClass) line: 553
> CDOTransactionImpl(AbstractCDOView).createObject(CDOID) line: 687
> CDOTransactionImpl(AbstractCDOView).getObject(CDOID, boolean) line: 605
> CDOTransactionImpl.getObject(CDOID, boolean) line: 885
> CDOTransactionImpl(AbstractCDOView).convertIDToObject(Object) line: 860
> CDOStoreImpl.convertIDToObject(InternalCDOView, EObject, EStructuralFeature, int, Object) line: 668
> CDOStoreImpl.convertToEMF(EObject, InternalCDORevision, EStructuralFeature, int, Object) line: 636
> CDOStoreImpl.get(InternalEObject, EStructuralFeature, int) line: 187
> CDOResourceImpl$ContentsCDOList(EStoreEObjectImpl$BasicEStoreEList<E>).delegateGet(int) line: 247
> CDOResourceImpl$ContentsCDOList(DelegatingEList<E>).primitiveGet(int) line: 267
> AbstractEList$NonResolvingEListIterator<E1>.doNext() line: 1063
> AbstractEList$NonResolvingEListIterator<E1>(AbstractEList$EIterator<E1>).next() line: 696
> EContentsEList$FeatureIteratorImpl<E>.hasNext() line: 443
> TransactionChangeRecorder.setTarget(Notifier) line: 155
> CDOObjectImpl$1(BasicNotifierImpl$EAdapterList<E>).didAdd(int, E) line: 127
> CDOObjectImpl$1.didAdd(int, Adapter) line: 419
> CDOObjectImpl$1.didAdd(int, Object) line: 1
> CDOObjectImpl$1(BasicEList<E>).addUnique(E) line: 425
> CDOObjectImpl$1(AbstractEList<E>).add(E) line: 307
> CDOObjectImpl$1(BasicNotifierImpl$EAdapterList<E>).add(E) line: 199
> ChangeRecorder.addAdapter(Notifier) line: 631
> ChangeRecorder.notifyChanged(Notification) line: 285
> ResourceSetImpl(BasicNotifierImpl).eNotify(Notification) line: 380
> ResourceSetImpl$ResourcesEList<E>(NotifyingListImpl<E>).dispatchNotification(Notification) line: 267
> ResourceSetImpl$ResourcesEList<E>(NotifyingListImpl<E>).addUnique(E) line: 300
> ResourceSetImpl$ResourcesEList<E>(AbstractEList<E>).add(E) line: 307
> ResourceSetImpl.createResource(URI, String) line: 426
> ResourceSetImpl.demandCreateResource(URI) line: 239
> ResourceSetImpl.getResource(URI, boolean) line: 391
> CDOTransactionImpl(AbstractCDOView).getResource(String, boolean) line: 416
> CDOTransactionImpl(AbstractCDOView).newResourceInstance(InternalCDORevision) line: 711
>
>
> This creation is successfull, and this new r1 instance is put in the objects map.
>
> Later, when trying to put the r1 we created at the beginning in the objects map, we realize that it has already been
> created, so we throw an illegal state exception.
>
>
> I just tested a solution in which, inside the cleanObject() method, we do not set the CDOState to CLEAN. This should
> be done later, once the object has been put to the 'objects' map (actually just after the registerObject() call). It
> seems to work, but I'll have to determine the impacts of such a fix.
>
> Am I missing something where that could explain my issue?
> Do anyone see the possible impacts of the proposed fix?
>
> Best Regards,
> Alex
Re: [CDO] "Different object was registered for OID XX" in Native mode [message #1007272 is a reply to message #902825] Tue, 05 February 2013 05:30 Go to previous messageGo to next message
Esteban Dugueperoux is currently offline Esteban Dugueperoux
Messages: 309
Registered: July 2009
Senior Member
I have created https://bugs.eclipse.org/bugs/show_bug.cgi?id=399956 for this issue with a JUnit test.
Re: [CDO] &quot;Different object was registered for OID XX&quot; in Native mode [message #1007281 is a reply to message #1007272] Tue, 05 February 2013 05:53 Go to previous message
Eike Stepper is currently offline Eike Stepper
Messages: 5502
Registered: July 2009
Senior Member
Am 05.02.2013 11:30, schrieb Esteban Dugueperoux:
> I have created https://bugs.eclipse.org/bugs/show_bug.cgi?id=399956 for this issue with a JUnit test.
Thank you! As you might already have figured I'm totally lost in various tasks at the moment. It may take a while until
I get to all the outstanding bugs...

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Previous Topic:[CDO] Error while importing xml cdo export file.
Next Topic:[CDO/Teneo/Hibernate] Multi user: Freeze on commit
Goto Forum:
  


Current Time: Thu Aug 28 23:39:40 EDT 2014

Powered by FUDForum. Page generated in 0.02144 seconds