You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by GESCONSULTOR - Óscar Bou <o....@gesconsultor.com> on 2014/04/29 21:49:48 UTC

java.lang.NullPointerException at org.datanucleus.ExecutionContextImpl.performManagedRelationships(ExecutionContextImpl.java:4003)

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


Re: java.lang.NullPointerException at org.datanucleus.ExecutionContextImpl.performManagedRelationships(ExecutionContextImpl.java:4003)

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Thanks for taking the time to document this, Oscar... I've added a note to
our website for this recommendation here [1]

Dan

[1]
http://isis.apache.org/components/objectstores/jdo/managed-1-to-m-relationships.html

~~~~~~~~~~~~~

On 1 May 2014 09:21, GESCONSULTOR - Óscar Bou <o....@gesconsultor.com>wrote:

>
> Just for others with the same problem.
>
> Seems there's a bug somewhere in DN, but there's an easy workaround.
>
>
> The situation generating the NPE was the following:
>
> Domain Entity:
>
> @PersistenceCapable
> @Inheritance(strategy = InheritanceStrategy.NEW_TABLE)
> public class InformationSystem extends ApplicationComponent {
>
>
>     // {{ ParentSystem (property)
>     private InformationSystem parentSystem;
>
>     @MemberOrder(sequence = "100")
>     @Column(allowsNull = "true")
>     public InformationSystem getParentSystem() {
>         return this.parentSystem;
>     }
>
>     public void setParentSystem(final InformationSystem
> partOfInformationSystem) {
>         this.parentSystem = partOfInformationSystem;
>     }
>
>     // }}
>
>     // {{ SubSystems (Collection)
>     @Persistent(mappedBy = "parentSystem", dependentElement = "false")
>     private SortedSet<InformationSystem> subSystems = new
> TreeSet<InformationSystem>();
>
>     @MemberOrder(sequence = "500")
>     public SortedSet<InformationSystem> getSubSystems() {
>         return this.subSystems;
>     }
>
>     public void setSubSystems(final SortedSet<InformationSystem>
> subSystems) {
>         this.subSystems = subSystems;
>     }
>
>     // }}
>
>    ...
>
> }
>
> Obviously, the exception is thrown because we are using managed
> relationships, so DN tries to keep synched both sides.
>
> That's relevant, because in this case we were trying to set the
> relationship as this:
>
> subSystem.setParentSystem(informationSystem);
>
> When executed, the previous line was causing the NPE on DataNucleus.
>
> If, instead, we update the bidir relationship with:
>
> informationSystem.getSubSystems().add(subSystem);
>
>
> It runs smoothly.
>
> As it was inside a Fixture, and we weren't wrapping the call, as in (an
> "idiom" we have adopted in all our domain code, unless properties/actions
> are hidden or disabled):
>
> wrapperFactory.wrap(subSystem).setParentSystem(informationSystem);
>
> The exception was thrown when persisting another entity, which in our
> case, also executes a this.getContainer().flush(), as any action executed
> inside a wrap(..).
>
>
> So, summarizing, when having a bidirectional 1-n relationship that must be
> automatically managed by DataNucleus, it's preferred to "add" to the
> parent's child collection, than set the parent on the child.
>
>
> HTH,
>
> Oscar
>
>
>
>
>
> El 29/04/2014, a las 23:13, Dan Haywood <da...@haywood-associates.co.uk>
> escribió:
>
>
> On 29 April 2014 21:34, GESCONSULTOR - Óscar Bou <o.bou@gesconsultor.com
> >wrote:
>
>
> 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();
>       }
>
>
>
> I think it's probably worth asking on the DN forum (Andy Jefferson).  Say
> you work with me.  He'll probably ask for a test case, but I guess you
> could explain that's intermittent and possibly a threading issue.
>
> Also, do note that we're not on the latest version of DN; very outside
> change that it's a bug that's been recently fixed.
>
>
>
>
>
> While trying as a workaround to "hide" the exception in a try - catch
> block, as in:
>
>
>        // 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()));
>        }
>
>
>
> Then the Isis transaction was not in the correct state:
>
> 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)
>
> Not sure how to deal with it ...
>
>
>
>
> Not sure I recommend this, but if you want to hack it, you could register a
> custom implementation of DomainObjectContainer that resets the
> IsisTransaction back to a good state (setState to IN_PROGRESS and
> setAbortCause to null.
>
> in isis.properties:
>
>
> isis.persistor.domain-object-container=org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault
>
> change as required...
>
> As I say, rather hacky, not sure it's to be recommended.
>
> Dan
>
>
>
> Ó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 <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.
>
>
>
>
>
>

Re: java.lang.NullPointerException at org.datanucleus.ExecutionContextImpl.performManagedRelationships(ExecutionContextImpl.java:4003)

Posted by GESCONSULTOR - Óscar Bou <o....@gesconsultor.com>.
Just for others with the same problem.

Seems there's a bug somewhere in DN, but there's an easy workaround.


The situation generating the NPE was the following:

Domain Entity:

@PersistenceCapable
@Inheritance(strategy = InheritanceStrategy.NEW_TABLE)
public class InformationSystem extends ApplicationComponent {


    // {{ ParentSystem (property)
    private InformationSystem parentSystem;

    @MemberOrder(sequence = "100")
    @Column(allowsNull = "true")
    public InformationSystem getParentSystem() {
        return this.parentSystem;
    }

    public void setParentSystem(final InformationSystem partOfInformationSystem) {
        this.parentSystem = partOfInformationSystem;
    }

    // }}

    // {{ SubSystems (Collection)
    @Persistent(mappedBy = "parentSystem", dependentElement = "false")
    private SortedSet<InformationSystem> subSystems = new TreeSet<InformationSystem>();

    @MemberOrder(sequence = "500")
    public SortedSet<InformationSystem> getSubSystems() {
        return this.subSystems;
    }

    public void setSubSystems(final SortedSet<InformationSystem> subSystems) {
        this.subSystems = subSystems;
    }

    // }}

   ...

}

Obviously, the exception is thrown because we are using managed relationships, so DN tries to keep synched both sides.

That's relevant, because in this case we were trying to set the relationship as this:

subSystem.setParentSystem(informationSystem);

When executed, the previous line was causing the NPE on DataNucleus.

If, instead, we update the bidir relationship with:

informationSystem.getSubSystems().add(subSystem);


It runs smoothly.

As it was inside a Fixture, and we weren't wrapping the call, as in (an "idiom" we have adopted in all our domain code, unless properties/actions are hidden or disabled):

wrapperFactory.wrap(subSystem).setParentSystem(informationSystem);

The exception was thrown when persisting another entity, which in our case, also executes a this.getContainer().flush(), as any action executed inside a wrap(..).


So, summarizing, when having a bidirectional 1-n relationship that must be automatically managed by DataNucleus, it's preferred to "add" to the parent's child collection, than set the parent on the child.


HTH,

Oscar





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

> On 29 April 2014 21:34, GESCONSULTOR - Óscar Bou <o....@gesconsultor.com>wrote:
> 
>> 
>> 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();
>>       }
>> 
>> 
>> 
> I think it's probably worth asking on the DN forum (Andy Jefferson).  Say
> you work with me.  He'll probably ask for a test case, but I guess you
> could explain that's intermittent and possibly a threading issue.
> 
> Also, do note that we're not on the latest version of DN; very outside
> change that it's a bug that's been recently fixed.
> 
> 
> 
> 
>> 
>> While trying as a workaround to "hide" the exception in a try - catch
>> block, as in:
>> 
>> 
>>        // 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()));
>>        }
>> 
>> 
>> 
>> Then the Isis transaction was not in the correct state:
>> 
>> 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)
>> 
>> Not sure how to deal with it ...
>> 
>> 
>> 
>> 
> Not sure I recommend this, but if you want to hack it, you could register a
> custom implementation of DomainObjectContainer that resets the
> IsisTransaction back to a good state (setState to IN_PROGRESS and
> setAbortCause to null.
> 
> in isis.properties:
> 
> isis.persistor.domain-object-container=org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault
> 
> change as required...
> 
> As I say, rather hacky, not sure it's to be recommended.
> 
> Dan


Ó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.






Re: java.lang.NullPointerException at org.datanucleus.ExecutionContextImpl.performManagedRelationships(ExecutionContextImpl.java:4003)

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 29 April 2014 21:34, GESCONSULTOR - Óscar Bou <o....@gesconsultor.com>wrote:

>
> 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();
>        }
>
>
>
I think it's probably worth asking on the DN forum (Andy Jefferson).  Say
you work with me.  He'll probably ask for a test case, but I guess you
could explain that's intermittent and possibly a threading issue.

Also, do note that we're not on the latest version of DN; very outside
change that it's a bug that's been recently fixed.




>
> While trying as a workaround to "hide" the exception in a try - catch
> block, as in:
>
>
>         // 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()));
>         }
>
>
>
> Then the Isis transaction was not in the correct state:
>
> 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)
>
> Not sure how to deal with it ...
>
>
>
>
Not sure I recommend this, but if you want to hack it, you could register a
custom implementation of DomainObjectContainer that resets the
IsisTransaction back to a good state (setState to IN_PROGRESS and
setAbortCause to null.

in isis.properties:

isis.persistor.domain-object-container=org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault

change as required...

As I say, rather hacky, not sure it's to be recommended.

Dan

Re: java.lang.NullPointerException at org.datanucleus.ExecutionContextImpl.performManagedRelationships(ExecutionContextImpl.java:4003)

Posted by GESCONSULTOR - Óscar Bou <o....@gesconsultor.com>.
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....@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.






Re: java.lang.NullPointerException at org.datanucleus.ExecutionContextImpl.performManagedRelationships(ExecutionContextImpl.java:4003)

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
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
>
>