It's probably a subtle missing bit of JDO metadata, but DN isn't failing fast. We've certainly seem this in Estatio on occasion (though not this precise error).
Looking at the performManagedRelationships() method, I see: RelationshipManager relMgr = managedRelationDetails.get(op); relMgr.process(); relMgr.clearFields(); towards the bottom of the method (quoted in full below). Presumably relMgr is null. It'd be worth putting a breakpoint there and poking around in that map. Then I'd have a look to see how that map is meant to be populated, looks like it is lazily populated in getRelationshipManager(), also quoted below. The only other place where this map is touched is in resetTransactionalVariables(). I wonder if there's a bug in DN there, because the map is cleared out but not set back to null: if (getManageRelations() && managedRelationDetails != null) { managedRelationDetails.clear(); } So, if this method were called prior to performManagedRelationships(), then an NPE would result. Hope that helps a little... Dan ~~~~ Method in full: /** * Method to perform managed relationships tasks. * @throws NucleusUserException if a consistency check fails */ protected void performManagedRelationships() { if (getManageRelations() && managedRelationDetails != null && !managedRelationDetails.isEmpty()) { try { runningManageRelations = true; if (NucleusLogger.PERSISTENCE.isDebugEnabled()) { NucleusLogger.PERSISTENCE.debug(LOCALISER.msg("013000")); } if (getManageRelationsChecks()) { // Tests for negative situations where inconsistently assigned for (ObjectProvider op : managedRelationDetails.keySet()) { LifeCycleState lc = op.getLifecycleState(); if (lc == null || lc.isDeleted()) { // Has been deleted so ignore all relationship changes continue; } RelationshipManager relMgr = managedRelationDetails.get(op); relMgr.checkConsistency(); } } // Process updates to manage the other side of the relations Iterator<ObjectProvider> opIter = managedRelationDetails.keySet().iterator(); while (opIter.hasNext()) { ObjectProvider op = opIter.next(); LifeCycleState lc = op.getLifecycleState(); if (lc == null || lc.isDeleted()) { // Has been deleted so ignore all relationship changes continue; } RelationshipManager relMgr = managedRelationDetails.get(op); relMgr.process(); relMgr.clearFields(); } managedRelationDetails.clear(); if (NucleusLogger.PERSISTENCE.isDebugEnabled()) { NucleusLogger.PERSISTENCE.debug(LOCALISER.msg("013001")); } } finally { runningManageRelations = false; } } } the managedRelationDetails is populated lazily: public RelationshipManager getRelationshipManager(ObjectProvider op) { if (!getManageRelations()) { return null; } if (managedRelationDetails == null) { managedRelationDetails = new ConcurrentHashMap(); } RelationshipManager relMgr = managedRelationDetails.get(op); if (relMgr == null) { relMgr = new RelationshipManagerImpl(op); managedRelationDetails.put(op, relMgr); } return relMgr; } Looks like it can also be cleared: /** * Convenience method to reset all state variables for the transaction, performed at commit/rollback. */ private void resetTransactionalVariables() { if (getReachabilityAtCommit()) { reachabilityEnlistedIds.clear(); reachabilityPersistedIds.clear(); reachabilityDeletedIds.clear(); reachabilityFlushedNewIds.clear(); } enlistedOPCache.clear(); dirtyOPs.clear(); indirectDirtyOPs.clear(); fetchPlan.resetDetachmentRoots(); if (getManageRelations() && managedRelationDetails != null) { managedRelationDetails.clear(); } // L2 cache processing if (l2CacheTxIds != null) { l2CacheTxIds.clear(); } if (l2CacheTxFieldsToUpdateById != null) { l2CacheTxFieldsToUpdateById.clear(); } if (operationQueue != null) { if (!operationQueue.getOperations().isEmpty()) { NucleusLogger.PERSISTENCE.warn("Queue of operations for flushing is not empty! Ignoring unprocessed operations. Generate a testcase and report this. See the log for full details of unflushed ops"); operationQueue.log(); } operationQueue.clear(); } opAttachDetachObjectReferenceMap = null; } On 29 April 2014 20:49, GESCONSULTOR - Óscar Bou <o....@gesconsultor.com>wrote: > Hi to all. > > I'm experimenting an exception, without having any idea about its source. > > It always happens in the context of the same class, that it's annotated > with @PersistenceCapable. > > Seems DataNucleus tries to automatically manage its relationships (by > adding elements to the collection, etc.) and it can't. > > Not sure if it's a DN problem, or an Isis related one ... > > Any ideas about how to advance on the resolution? > > Many thanks!!! > > > > java.lang.RuntimeException: java.lang.NullPointerException > at > org.apache.isis.core.integtestsupport.IsisSystemForTest.setUpSystem(IsisSystemForTest.java:284) > at > com.xms.framework.risk.integration.RiskSystemInitializerWithBCMFixture.initIsft(RiskSystemInitializerWithBCMFixture.java:70) > at > com.xms.framework.risk.integration.RiskIntegTestAbstractWithBCMFixture.initClass(RiskIntegTestAbstractWithBCMFixture.java:14) > 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:47) > at > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) > at > org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) > at > org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) > at org.junit.runners.ParentRunner.run(ParentRunner.java:309) > 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 > org.datanucleus.ExecutionContextImpl.performManagedRelationships(ExecutionContextImpl.java:4003) > at > org.datanucleus.ExecutionContextImpl.flush(ExecutionContextImpl.java:4067) > at > org.datanucleus.api.jdo.JDOPersistenceManager.flush(JDOPersistenceManager.java:2010) > at > org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.executeCommands(DataNucleusObjectStore.java:363) > at > org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.execute(DataNucleusObjectStore.java:355) > at > org.apache.isis.core.runtime.system.transaction.IsisTransaction.doFlush(IsisTransaction.java:420) > at > org.apache.isis.core.runtime.system.transaction.IsisTransaction.flush(IsisTransaction.java:369) > at > org.apache.isis.core.runtime.system.transaction.IsisTransactionManager.flushTransaction(IsisTransactionManager.java:311) > at > org.apache.isis.core.runtime.persistence.internal.RuntimeContextFromSession$7.flush(RuntimeContextFromSession.java:223) > at > org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault.flush(DomainObjectContainerDefault.java:229) > at > com.xms.framework.api.domain.model.isis.AbstractXMSDomainObjectRepositoryAndFactory.persist(AbstractXMSDomainObjectRepositoryAndFactory.java:59) > at > com.xms.framework.architecture.domain.model.valuation.ConsequenceByDimensionAndCriterionMatrices.createMatrix(ConsequenceByDimensionAndCriterionMatrices.java:18) > at sun.reflect.GeneratedMethodAccessor163.invoke(Unknown Source) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at > org.apache.isis.core.progmodel.facets.actions.invoke.ActionInvocationFacetViaMethod.invoke(ActionInvocationFacetViaMethod.java:178) > at > org.apache.isis.core.runtime.transaction.facets.ActionInvocationFacetWrapTransaction$1.execute(ActionInvocationFacetWrapTransaction.java:57) > at > org.apache.isis.core.runtime.transaction.facets.ActionInvocationFacetWrapTransaction$1.execute(ActionInvocationFacetWrapTransaction.java:54) > at > org.apache.isis.core.runtime.system.transaction.IsisTransactionManager.executeWithinTransaction(IsisTransactionManager.java:223) > at > org.apache.isis.core.runtime.transaction.facets.ActionInvocationFacetWrapTransaction.invoke(ActionInvocationFacetWrapTransaction.java:54) > at > org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionImpl.execute(ObjectActionImpl.java:342) > at > org.apache.isis.core.wrapper.internal.DomainObjectInvocationHandler.handleActionMethod(DomainObjectInvocationHandler.java:509) > at > org.apache.isis.core.wrapper.internal.DomainObjectInvocationHandler.invoke(DomainObjectInvocationHandler.java:236) > at > org.apache.isis.core.wrapper.internal.InvocationHandlerMethodInterceptor.intercept(InvocationHandlerMethodInterceptor.java:37) > at > com.xms.framework.architecture.domain.model.valuation.ConsequenceByDimensionAndCriterionMatrices$$EnhancerByCGLIB$$5428e512.createMatrix(<generated>) > at > com.xms.framework.architecture.domain.model.EnterpriseArchitectureModel.internalCreatePersistentAsset(EnterpriseArchitectureModel.java:420) > at > com.xms.framework.architecture.domain.model.EnterpriseArchitectureModel.createBusinessInteraction(EnterpriseArchitectureModel.java:887) > at > com.xms.framework.architecture.fixtures.EnterpriseArchitectureFixture.installCMDBModel(EnterpriseArchitectureFixture.java:242) > at > com.xms.framework.architecture.fixtures.EnterpriseArchitectureFixture.install(EnterpriseArchitectureFixture.java:82) > at > com.xms.framework.architecture.fixtures.EnterpriseArchitectureFixtureService.installDemoData(EnterpriseArchitectureFixtureService.java:29) > at > com.xms.framework.continuity.fixtures.BCMFixture.installArchitectureFixture(BCMFixture.java:118) > at > com.xms.framework.continuity.fixtures.BCMFixture.install(BCMFixture.java:37) > at > org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate.installFixture(FixturesInstallerDelegate.java:229) > at > org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate.installFixtureInTransaction(FixturesInstallerDelegate.java:191) > at > org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate.installFixtures(FixturesInstallerDelegate.java:178) > at > org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate.installFixtures(FixturesInstallerDelegate.java:158) > at > org.apache.isis.core.integtestsupport.IsisSystemForTest.wireAndInstallFixtures(IsisSystemForTest.java:321) > at > org.apache.isis.core.integtestsupport.IsisSystemForTest.setUpSystem(IsisSystemForTest.java:312) > at > org.apache.isis.core.integtestsupport.IsisSystemForTest.setUpSystem(IsisSystemForTest.java:282) > ... 17 more > >