Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » NPE and other unmotivated exceptions(Errors in Eclipselink 2.3.0 JPA with POJO)
NPE and other unmotivated exceptions [message #761327] Tue, 06 December 2011 09:48 Go to next message
roman  is currently offline roman Friend
Messages: 4
Registered: December 2011
Location: Austria
Junior Member
Hi there,

we experience severe problems using eclipselink 2.3.x JPA with POJO. We are writing an application that inserts and updates entities with a lot of master/detail relationships.

Inserting works fine, but if we want to update/delete an existing entity, we get a lot of unmotivated exceptions during flush or commit (even if a flush directly before the commit works).

First problem:
lookup an entiy (through em.find() with CacheRetrieveMode.BYPASS) and delete two child entities from the map results in:
javax.persistence.RollbackException: java.lang.NullPointerException
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:102)
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
	at eu.lbase.prod.common.model.AbstractEntityManagerTest.deleteSkom(AbstractEntityManagerTest.java:448)
	at eu.lbase.prod.common.model.AbstractEntityManagerTest.testDeleteSkom2(AbstractEntityManagerTest.java:396)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.NullPointerException
	at java.util.Hashtable.remove(Hashtable.java:436)
	at org.eclipse.persistence.indirection.IndirectMap.remove(IndirectMap.java:599)
	at org.eclipse.persistence.indirection.IndirectMap.remove(IndirectMap.java:599)
	at org.eclipse.persistence.internal.queries.MapContainerPolicy.removeFrom(MapContainerPolicy.java:730)
	at org.eclipse.persistence.internal.queries.ContainerPolicy.mergeChanges(ContainerPolicy.java:1068)
	at org.eclipse.persistence.mappings.CollectionMapping.mergeChangesIntoObject(CollectionMapping.java:1334)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.mergeChangesIntoObject(ObjectBuilder.java:3409)
	at org.eclipse.persistence.internal.sessions.MergeManager.mergeChangesOfWorkingCopyIntoOriginal(MergeManager.java:744)
	at org.eclipse.persistence.internal.sessions.MergeManager.mergeChangesOfWorkingCopyIntoOriginal(MergeManager.java:617)
	at org.eclipse.persistence.internal.sessions.MergeManager.mergeChanges(MergeManager.java:267)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.mergeChangesIntoParent(UnitOfWorkImpl.java:3254)
	at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.mergeChangesIntoParent(RepeatableWriteUnitOfWork.java:370)
	at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:284)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1143)
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84)
	... 29 more


Second problem:
lookup an entity twice (with CacheRetrieveMode.BYPASS), than change one of them (change values of that entity and delete/insert child entities):
javax.persistence.RollbackException: Exception [EclipseLink-6054] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.QueryException
Exception Description: Cannot add the object [eu.lbase.prod.common.model.SanpAnsprechp@1a53800], of class [class eu.lbase.prod.common.model.SanpAnsprechp], to container class [class org.eclipse.persistence.indirection.IndirectMap] using policy [MappedKeyMapContainerPolicy(class org.eclipse.persistence.indirection.IndirectMap)].
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:102)
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
	at eu.lbase.prod.common.model.AbstractEntityManagerTest.deleteAndInsertChildRecords(AbstractEntityManagerTest.java:290)
	at eu.lbase.prod.common.model.AbstractEntityManagerTest.testDeleteAndInsertChildRecords2(AbstractEntityManagerTest.java:222)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: Exception [EclipseLink-6054] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.QueryException
Exception Description: Cannot add the object [eu.lbase.prod.common.model.SanpAnsprechp@1a53800], of class [class eu.lbase.prod.common.model.SanpAnsprechp], to container class [class org.eclipse.persistence.indirection.IndirectMap] using policy [MappedKeyMapContainerPolicy(class org.eclipse.persistence.indirection.IndirectMap)].
	at org.eclipse.persistence.exceptions.QueryException.cannotAddToContainer(QueryException.java:351)
	at org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy.addInto(MappedKeyMapContainerPolicy.java:176)
	at org.eclipse.persistence.mappings.CollectionMapping.mergeChangesIntoObject(CollectionMapping.java:1358)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.mergeChangesIntoObject(ObjectBuilder.java:3409)
	at org.eclipse.persistence.internal.sessions.MergeManager.mergeChangesOfWorkingCopyIntoOriginal(MergeManager.java:744)
	at org.eclipse.persistence.internal.sessions.MergeManager.mergeChangesOfWorkingCopyIntoOriginal(MergeManager.java:617)
	at org.eclipse.persistence.internal.sessions.MergeManager.mergeChanges(MergeManager.java:267)
	at org.eclipse.persistence.mappings.ObjectReferenceMapping.mergeIntoObject(ObjectReferenceMapping.java:462)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.mergeIntoObject(ObjectBuilder.java:3466)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.mergeChangesIntoObject(ObjectBuilder.java:3400)
	at org.eclipse.persistence.internal.sessions.MergeManager.mergeChangesOfWorkingCopyIntoOriginal(MergeManager.java:744)
	at org.eclipse.persistence.internal.sessions.MergeManager.mergeChangesOfWorkingCopyIntoOriginal(MergeManager.java:617)
	at org.eclipse.persistence.internal.sessions.MergeManager.mergeChanges(MergeManager.java:267)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.mergeChangesIntoParent(UnitOfWorkImpl.java:3254)
	at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.mergeChangesIntoParent(RepeatableWriteUnitOfWork.java:370)
	at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:284)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1143)
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84)
	... 29 more



Third problem:
lookup an entity, detach the entity, change values, merge the entity back, than do the same with child entities:
javax.persistence.RollbackException: Exception [EclipseLink-69] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: A NullPointerException was thrown while extracting a value from the instance variable [zadAdrid] in the object [null].
Internal Exception: java.lang.NullPointerException
Mapping: org.eclipse.persistence.mappings.DirectToFieldMapping[zadAdrid-->SZAD_ADRORG.ZAD_ADRID]
Descriptor: RelationalDescriptor(eu.lbase.prod.common.model.SzadAdrorgPK --> [DatabaseTable(SZAD_ADRORG)])
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:102)
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
	at eu.lbase.prod.common.model.AbstractEntityManagerTest.updateAddress(AbstractEntityManagerTest.java:371)
	at eu.lbase.prod.common.model.AbstractEntityManagerTest.testUpdateAddress(AbstractEntityManagerTest.java:305)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: Exception [EclipseLink-69] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: A NullPointerException was thrown while extracting a value from the instance variable [zadAdrid] in the object [null].
Internal Exception: java.lang.NullPointerException
Mapping: org.eclipse.persistence.mappings.DirectToFieldMapping[zadAdrid-->SZAD_ADRORG.ZAD_ADRID]
Descriptor: RelationalDescriptor(eu.lbase.prod.common.model.SzadAdrorgPK --> [DatabaseTable(SZAD_ADRORG)])
	at org.eclipse.persistence.exceptions.DescriptorException.nullPointerWhileGettingValueThruInstanceVariableAccessor(DescriptorException.java:1263)
	at org.eclipse.persistence.internal.descriptors.InstanceVariableAttributeAccessor.getAttributeValueFromObject(InstanceVariableAttributeAccessor.java:88)
	at org.eclipse.persistence.mappings.DatabaseMapping.getAttributeValueFromObject(DatabaseMapping.java:516)
	at org.eclipse.persistence.mappings.DatabaseMapping.getRealAttributeValueFromObject(DatabaseMapping.java:660)
	at org.eclipse.persistence.descriptors.CMPPolicy.createPrimaryKeyInstance(CMPPolicy.java:423)
	at org.eclipse.persistence.internal.queries.MapContainerPolicy.keyFrom(MapContainerPolicy.java:581)
	at org.eclipse.persistence.internal.queries.MapContainerPolicy.compareKeys(MapContainerPolicy.java:265)
	at org.eclipse.persistence.internal.queries.ContainerPolicy.collectObjectForNewCollection(ContainerPolicy.java:485)
	at org.eclipse.persistence.internal.queries.ContainerPolicy.compareCollectionsForChange(ContainerPolicy.java:551)
	at org.eclipse.persistence.mappings.CollectionMapping.compareCollectionsForChange(CollectionMapping.java:483)
	at org.eclipse.persistence.mappings.CollectionMapping.compareForChange(CollectionMapping.java:523)
	at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.createObjectChangeSetThroughComparison(DeferredChangeDetectionPolicy.java:177)
	at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.createObjectChangeSet(DeferredChangeDetectionPolicy.java:137)
	at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChanges(DeferredChangeDetectionPolicy.java:89)
	at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChangesForExistingObject(DeferredChangeDetectionPolicy.java:54)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.calculateChanges(UnitOfWorkImpl.java:643)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1490)
	at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:267)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1143)
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84)
	... 29 more
Caused by: java.lang.NullPointerException
	at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:36)
	at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18)
	at java.lang.reflect.Field.get(Field.java:358)
	at org.eclipse.persistence.internal.descriptors.InstanceVariableAttributeAccessor.getAttributeValueFromObject(InstanceVariableAttributeAccessor.java:76)
	... 47 more


Fourth problem:
same as above, but before that insert the entity with the same entitymanager.
javax.persistence.RollbackException: Exception [EclipseLink-6004] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.QueryException
Exception Description: The object [eu.lbase.prod.common.model.SzadAdrorg@142ef25], of class [class eu.lbase.prod.common.model.SzadAdrorg], with identity hashcode (System.identityHashCode()) [21.163.813], 
is not from this UnitOfWork object space, but the parent session's.  The object was never registered in this UnitOfWork, 
but read from the parent session and related to an object registered in the UnitOfWork.  Ensure that you are correctly
registering your objects.  If you are still having problems, you can use the UnitOfWork.validateObjectSpace() method to 
help debug where the error occurred.  For more information, see the manual or FAQ.
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:102)
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
	at eu.lbase.prod.common.model.AbstractEntityManagerTest.updateAddress(AbstractEntityManagerTest.java:371)
	at eu.lbase.prod.common.model.AbstractEntityManagerTest.testUpdateAddress2(AbstractEntityManagerTest.java:322)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: Exception [EclipseLink-6004] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.QueryException
Exception Description: The object [eu.lbase.prod.common.model.SzadAdrorg@142ef25], of class [class eu.lbase.prod.common.model.SzadAdrorg], with identity hashcode (System.identityHashCode()) [21.163.813], 
is not from this UnitOfWork object space, but the parent session's.  The object was never registered in this UnitOfWork, 
but read from the parent session and related to an object registered in the UnitOfWork.  Ensure that you are correctly
registering your objects.  If you are still having problems, you can use the UnitOfWork.validateObjectSpace() method to 
help debug where the error occurred.  For more information, see the manual or FAQ.
	at org.eclipse.persistence.exceptions.QueryException.backupCloneIsOriginalFromParent(QueryException.java:285)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.getBackupClone(UnitOfWorkImpl.java:1981)
	at org.eclipse.persistence.internal.queries.MapContainerPolicy.compareKeys(MapContainerPolicy.java:264)
	at org.eclipse.persistence.internal.queries.ContainerPolicy.collectObjectForNewCollection(ContainerPolicy.java:485)
	at org.eclipse.persistence.internal.queries.ContainerPolicy.compareCollectionsForChange(ContainerPolicy.java:551)
	at org.eclipse.persistence.mappings.CollectionMapping.compareCollectionsForChange(CollectionMapping.java:483)
	at org.eclipse.persistence.mappings.CollectionMapping.compareForChange(CollectionMapping.java:523)
	at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.createObjectChangeSetThroughComparison(DeferredChangeDetectionPolicy.java:177)
	at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.createObjectChangeSet(DeferredChangeDetectionPolicy.java:137)
	at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChanges(DeferredChangeDetectionPolicy.java:89)
	at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChangesForExistingObject(DeferredChangeDetectionPolicy.java:54)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.calculateChanges(UnitOfWorkImpl.java:643)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1490)
	at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:267)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1143)
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84)
	... 29 more



We identified, that a lot of problems occur, if we use detach/merge and can be omitted, if we dont do that. But a few errors still occur without detach/merge.

We experimented with "orphans-removal=true", but that didnt help.

We experimented with disabling the cache (since the data is manipulated through other applications as well). That helped a bit, but brought other problems (stack overflow in 1:1 relationships), unwanted database queries (in a 1:n relation, if the master triggers the population of the child-map, for each child record, the master is selected again from the database).

I attach a small Eclipse project with unittests, showing the problems we ran into.

Please have a look to it.


we are testing with eclipselink from indigo (2.3.0) against an oracle database 10g. Our application is designed to be a long running osgi application (since the startup of the eclipselink framework takes 1-2 seconds), but we normally clear the entitymanager after each transaction (commit).

Thanks,
Roman
Re: NPE and other unmotivated exceptions [message #762628 is a reply to message #761327] Thu, 08 December 2011 12:17 Go to previous messageGo to next message
roman  is currently offline roman Friend
Messages: 4
Registered: December 2011
Location: Austria
Junior Member
I did some further investigation.

enclosed is a new version of the project, where we changed the 1:n relationships in the entities from "Map" to "Set".

There is not one Unittest failing.

So it seems, that either we are missing some "needed configuration" when using Map for relations, or the implementation of Map for relations is extremely buggy in eclipselink.
Re: NPE and other unmotivated exceptions [message #762698 is a reply to message #762628] Thu, 08 December 2011 14:22 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

These may be more than one issue. But they seem to be related to your Map usage. What is the mapping/code for the class causing the error?

The error seems to be the key used for the Map has not yet been merged when the Map is being merged.

Does the error still occur without CacheRetrieveMode.BYPASS?

Please log a bug for the issue and include the details and code.

To disable the cache set shared to false, do not set the cache type to none.

See,
http://wiki.eclipse.org/EclipseLink/FAQ/How_to_disable_the_shared_cache%3F


James : Wiki : Book : Blog : Twitter
Re: NPE and other unmotivated exceptions [message #762703 is a reply to message #762628] Thu, 08 December 2011 14:22 Go to previous messageGo to next message
James is currently offline JamesFriend
Messages: 272
Registered: July 2009
Senior Member
These may be more than one issue. But they seem to be related to your Map usage. What is the mapping/code for the class causing the error?

The error seems to be the key used for the Map has not yet been merged when the Map is being merged.

Does the error still occur without CacheRetrieveMode.BYPASS?

Please log a bug for the issue and include the details and code.

To disable the cache set shared to false, do not set the cache type to none.

See,
http://wiki.eclipse.org/EclipseLink/FAQ/How_to_disable_the_shared_cache%3F
--
James : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/
Re: NPE and other unmotivated exceptions [message #762770 is a reply to message #762698] Thu, 08 December 2011 15:49 Go to previous messageGo to next message
roman  is currently offline roman Friend
Messages: 4
Registered: December 2011
Location: Austria
Junior Member
Hi James,

yes, there are more issues, and all seem to be related to the Map usage.

Most important is, that the errors dont occur on a call to persist, most of them occur on a call to commit(), even if immediately before the commit, a flush() didn't show any problem. So these issues have to be related to eclipselink internals.

In the sample we use different Map-Keys. From a simple "String" to a complex PrimaryKey defined with the annotation "EmbeddedId". But it makes no big difference for the exceptions, they also occur on the simplest mappings.

If we don't use the CacheRetrieveMode.BYPASS, some of the errors dont occur, but not all of them. It would be one workaround to find() and then refresh(), but to be honest, thats not really nice programming, since in "most" cases we would query the database twice.

Disabling the complete caching mechanism was just a try to identify where the problems are, so completely disabling the 2nd level cache is not really an option for us. But I tried the setting with the test project and most (but not all) of the errors dont occur. So this is a good advice for the eclipselink developers to search for the errors in cache coordination.

Thanks,
Roman
Re: NPE and other unmotivated exceptions [message #762772 is a reply to message #762698] Thu, 08 December 2011 15:49 Go to previous messageGo to next message
roman is currently offline romanFriend
Messages: 4
Registered: July 2009
Junior Member
Hi James,

yes, there are more issues, and all seem to be related to the Map usage.

Most important is, that the errors dont occur on a call to persist, most of them occur on a call to commit(), even if immediately before the commit, a flush() didn't show any problem. So these issues have to be related to eclipselink internals.

In the sample we use different Map-Keys. From a simple "String" to a complex PrimaryKey defined with the annotation "EmbeddedId". But it makes no big difference for the exceptions, they also occur on the simplest mappings.

If we don't use the CacheRetrieveMode.BYPASS, some of the errors dont occur, but not all of them. It would be one workaround to find() and then refresh(), but to be honest, thats not really nice programming, since in "most" cases we would query the database twice.

Disabling the complete caching mechanism was just a try to identify where the problems are, so completely disabling the 2nd level cache is not really an option for us. But I tried the setting with the test project and most (but not all) of the errors dont occur. So this is a good advice for the eclipselink developers to search for the errors in cache coordination.

Thanks,
Roman
Re: NPE and other unmotivated exceptions [message #762795 is a reply to message #762772] Thu, 08 December 2011 16:21 Go to previous message
roman  is currently offline roman Friend
Messages: 4
Registered: December 2011
Location: Austria
Junior Member
logged bug 366059
Previous Topic:Re: java.lang.LinkageError: loader (instance of sun/misc/Launcher$AppClassLoader): attempted dupli
Next Topic:NPE in AbstractRecord.get() after failed insert
Goto Forum:
  


Current Time: Tue Apr 23 09:01:56 GMT 2024

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

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

Back to the top