atom feed6 messages in org.apache.incubator.isis-usersRe: java.lang.NullPointerException at...
FromSent OnAttachments
GESCONSULTOR - Óscar BouApr 29, 2014 12:49 pm 
Dan HaywoodApr 29, 2014 1:04 pm 
GESCONSULTOR - Óscar BouApr 29, 2014 1:34 pm.gif, .tiff, .gif, 2 more
Dan HaywoodApr 29, 2014 2:13 pm 
GESCONSULTOR - Óscar BouMay 1, 2014 1:21 am.gif, .tiff, .gif, 2 more
Dan HaywoodMay 1, 2014 4:10 am 
Subject:Re: java.lang.NullPointerException at org.datanucleus.ExecutionContextImpl.performManagedRelationships(ExecutionContextImpl.java:4003)
From:GESCONSULTOR - Óscar Bou (o.b@gesconsultor.com)
Date:Apr 29, 2014 1:34:19 pm
List:org.apache.incubator.isis-users
Attachments:
Pasted Graphic 1.tiff - 2k

Yes... relMgr is what I find to be null...

I noticed it sometimes worked, sometimes not... I thought about a limit in
nested transactions or something similar... But I didn't noticed it was a
ConcurrentMap.

The only option seems the one you pointed. The Map has been cleared and not
initialized on:

if (getManageRelations() && managedRelationDetails != null) { managedRelationDetails.clear(); }

While trying as a workaround to "hide" the exception in a try - catch block, as
in:

@Override @Programmatic protected <T> T persist(final T transientDomainObject) {

// Ensure the Domain Object is persisted in a valid state. this.validate(transientDomainObject);

// Prepare the command to persist the domain object. final T savedObject = super.persist(transientDomainObject);

// Send pending changes to the database. try { this.getContainer().flush(); } catch (final NullPointerException e) { // Do nothing... Seems there's a bug in DN when updating Managed // Relationships. // It only occurs sometimes (it's lacy loaded; it's a multi-threaded // ConcurrentMap. System.err.print(String.format("XMS - FLUSING ERROR !!!: %s",
e.getStackTrace().toString())); }

return savedObject; }

Then the Isis transaction was not in the correct state:

java.lang.RuntimeException: java.lang.IllegalStateException: state is:
MUST_ABORT at
org.apache.isis.core.integtestsupport.IsisSystemForTest.setUpSystem(IsisSystemForTest.java:284) at
com.xms.framework.risk.integration.RiskSystemInitializerWithBCMFixture.initIsft(RiskSystemInitializerWithBCMFixture.java:73) 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.IllegalStateException: state is: MUST_ABORT at org.apache.isis.core.commons.ensure.Ensure.ensureThatState(Ensure.java:111) at
org.apache.isis.core.runtime.system.transaction.IsisTransaction.flush(IsisTransaction.java:363) 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.AbstractXMSDomainObject.persist(AbstractXMSDomainObject.java:271) at
com.xms.framework.architecture.domain.model.EnterpriseArchitectureModel.internalCreatePersistentAsset(EnterpriseArchitectureModel.java:434) at
com.xms.framework.architecture.domain.model.EnterpriseArchitectureModel.createFileSystem(EnterpriseArchitectureModel.java:1525) at
com.xms.framework.architecture.fixtures.EnterpriseArchitectureFixture.installCMDBModel(EnterpriseArchitectureFixture.java:296) at
com.xms.framework.architecture.fixtures.EnterpriseArchitectureFixture.install(EnterpriseArchitectureFixture.java:82) at
com.xms.framework.architecture.fixtures.EnterpriseArchitectureFixtureService.installDemoData(EnterpriseArchitectureFixtureService.java:25) 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

Not sure how to deal with it ...

El 29/04/2014, a las 22:04, Dan Haywood <da@haywood-associates.co.uk> escribió:

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.b@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

Óscar Bou Bou Responsable de Producto Auditor Jefe de Certificación ISO 27001 en BSI CISA, CRISC, APMG ISO 20000, ITIL-F

902 900 231 / 620 267 520 http://www.twitter.com/oscarbou

http://es.linkedin.com/in/oscarbou

http://www.GesConsultor.com

Este mensaje y los ficheros anexos son confidenciales. Los mismos contienen
información reservada que no puede ser difundida. Si usted ha recibido este
correo por error, tenga la amabilidad de eliminarlo de su sistema y avisar al
remitente mediante reenvío a su dirección electrónica; no deberá copiar el
mensaje ni divulgar su contenido a ninguna persona. Su dirección de correo electrónico junto a sus datos personales constan en un
fichero titularidad de Gesdatos Software, S.L. cuya finalidad es la de mantener
el contacto con Ud. Si quiere saber de qué información disponemos de Ud.,
modificarla, y en su caso, cancelarla, puede hacerlo enviando un escrito al
efecto, acompañado de una fotocopia de su D.N.I. a la siguiente dirección:
Gesdatos Software, S.L. , Paseo de la Castellana, 153 bajo - 28046 (Madrid), y
Avda. Cortes Valencianas num. 50, 1ºC - 46015 (Valencia). Asimismo, es su
responsabilidad comprobar que este mensaje o sus archivos adjuntos no contengan
virus informáticos, y en caso que los tuvieran eliminarlos.