Issue #544: NullPointer when accessing persistent field

Type: Bug ReoprtVersion: 2.3.2Priority: NormalStatus: FixedReplies: 7
#1

I am afraid this is a large and complex example, and I do not encounter the problem in simple cases, therefore there is no example attached. I appreciate this may make the bug unreproduceable from your end.

 

[ObjectDB 2.3.2] Unexpected exception (Error 990)
  Generated by Java HotSpot(TM) Server VM 1.6.0_27 (on Windows Server 2008 6.0).
Please report this error on http://www.objectdb.com/database/issue/new
com.objectdb.o.InternalException: java.lang.NullPointerException: null
java.lang.NullPointerException
at com.objectdb.o.ISP.size(ISP.java:153)
at com.objectdb.o.CLT.visitRefs(CLT.java:156)
at com.objectdb.o.TVS.j(TVS.java:169)
at com.objectdb.o.TVS.cascade(TVS.java:156)
at com.objectdb.o.STA.Q(STA.java:476)
at com.objectdb.o.STM.D(STM.java:390)
at com.objectdb.o.OBM.bJ(OBM.java:884)
at com.objectdb.jdo.PMImpl.bJ(PMImpl.java:2186)
at com.objectdb.o.OBM.bI(OBM.java:800)
at com.objectdb.o.OBM.bH(OBM.java:750)
at com.objectdb.o.QRR.b(QRR.java:137)
at com.objectdb.o.QRR.b(QRR.java:634)
at com.objectdb.o.UMR.u(UMR.java:501)
at com.objectdb.o.ENT.loadInverse(ENT.java:1284)
at com.objectdb.o.IVP.g(IVP.java:96)
at com.objectdb.o.IVP.f(IVP.java:83)
at com.objectdb.o.ISP.iterator(ISP.java:126)
at java.util.Collections$UnmodifiableCollection$1.<init>(Collections.java:1007)
at java.util.Collections$UnmodifiableCollection.iterator(Collections.java:1006)
at com.aqera.utilitymanager.scheme.tasks.ActivityWait.execute_Completion(ActivityWait.java:748)
at com.aqera.utilitymanager.scheme.tasks.ActivityWait.execute_D1(ActivityWait.java:712)
at com.aqera.utilitymanager.scheme.tasks.ActivityWait.end_AwaitOutCome(ActivityWait.java:789)
at com.aqera.utilitymanager.scheme.tasks.ActivityWait.receiveEvent_Completion(ActivityWait.java:639)
at com.aqera.utilitymanager.scheme.tasks.ActivityWait.generateCallEvent(ActivityWait.java:585)
at com.aqera.utilitymanager.scheme.tasks.ActivityWait.completionSignal(ActivityWait.java:524)
at com.aqera.utilitymanager.scheme.tasks.ActivityWait.z_completion(ActivityWait.java:352)
at com.aqera.utilitymanager.scheme.tasks.ActivityWait.completion(ActivityWait.java:367)
at com.aqera.utilitymanager.scheme.tasks.RegisterActivity.z_receiveWaitingNotification(RegisterActivity.java:421)
at com.aqera.utilitymanager.scheme.tasks.RegisterActivity.receiveWaitingNotification(RegisterActivity.java:439)
at com.aqera.utilitymanager.scheme.registers.UtilityServicesSingleton.z_activityWaitingNotification(UtilityServicesSingleton.java:1174)
at com.aqera.utilitymanager.scheme.registers.UtilityServicesSingleton.activityWaitingNotification(UtilityServicesSingleton.java:1206)
at com.aqera.utilitymanager.scheme.services.myservices.UtilityActivityServicesBeanImpl.z_activityWaitingNotification(UtilityActivityServicesBeanImpl.java:160)
at com.aqera.utilitymanager.scheme.services.myservices.UtilityActivityServicesBeanImpl.activityWaitingNotification(UtilityActivityServicesBeanImpl.java:149)
at com.aqera.domains.jurisdiction.registers.Jurisdiction.execute_StartRegulatedScheme(Jurisdiction.java:1489)
at com.aqera.domains.jurisdiction.registers.Jurisdiction.execute_M3(Jurisdiction.java:1332)
at com.aqera.domains.jurisdiction.registers.Jurisdiction.end_JurisdictionEstablished(Jurisdiction.java:1551)
at com.aqera.domains.jurisdiction.registers.Jurisdiction.receiveEvent_StartRegulatedScheme(Jurisdiction.java:1245)
at com.aqera.domains.jurisdiction.services.testing.SchemeRegisterTestingServiceBeanImpl.z_createSchemeInJurisdiction(SchemeRegisterTestingServiceBeanImpl.java:55)
at com.aqera.domains.jurisdiction.services.testing.SchemeRegisterTestingServiceBeanImpl.createSchemeInJurisdiction(SchemeRegisterTestingServiceBeanImpl.java:38)
at com.aqera.domains.one.tests.InitializationTest.testCreateSchemeAndRegister(InitializationTest.java:126)
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 junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at com.aqera.domains.one.tests.InitializationTest.runBare(InitializationTest.java:31)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at com.aqera.domains.one.tests.SimulatorTestSuite$1.run(SimulatorTestSuite.java:60)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
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)

If the stack trace is no use I can send a zip of the entire example, which runs from the command line under maven ( I will have to send you a snapshot of some of the utility dependencies )

 

The code being called is accessing a map declared as follows;

@OneToMany(cascade=CascadeType.ALL, mappedBy="z_component")
@MapKey(name="z_schemeName")
    private java.util.Map<java.lang.String, com.aqera.domains.jurisdiction.regulatedschemes.RegulatedScheme> z_regulatedSchemes  = new java.util.HashMap<java.lang.String, com.aqera.domains.jurisdiction.regulatedschemes.RegulatedScheme>();

 

I have attached the log and db files ( transaction is rolled back )

 

The packages were all enhanced ( static weaving ).

 

#2

The following test case reproduces the exception. It may be thrown on accessing an inverse collection in an entity that has been garbage collected. Build 2.3.2_01 fixes it (at least this test case works now).

import java.util.List;

import javax.persistence.*;

public class T544 {
   
    public static void main(String[] args) {

        EntityManagerFactory emf =
            Persistence.createEntityManagerFactory(
                "objectdb:$objectdb/db/test.tmp;drop");

        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        A a = new A();
        B b = new B();
        b.a = a;
        em.persist(a);
        em.persist(b);
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        a = em.createQuery("SELECT a FROM A a", A.class).getSingleResult();
        List<B> list = a.list;
        a = null;
        System.gc();
        System.out.println(list.size());
        em.close();

        emf.close();
    }

    @Entity
    public static class A {
        @OneToMany(targetEntity = B.class, mappedBy = "a")
        private List<B> list;
    }

    @Entity
    public static class B {
        A a;
    }
}
ObjectDB Support
#3

Kudos! Thanks.

I no longer have that problem, but a Type not found 301 error, and will implement workaround for that and let you know.

#4

Unfortunately I have a similar problem, now I have passed the type 301 error.

 

[ObjectDB 2.3.2_01] Unexpected exception (Error 990)
  Generated by Java HotSpot(TM) Server VM 1.6.0_27 (on Windows Server 2008 6.0).
Please report this error on http://www.objectdb.com/database/issue/new
com.objectdb.o.InternalException: java.lang.NullPointerException: null
java.lang.NullPointerException
at com.objectdb.o.ISP.size(ISP.java:153)
at com.objectdb.o.CLT.visitRefs(CLT.java:156)
at com.objectdb.o.TVS.j(TVS.java:169)
at com.objectdb.o.TVS.cascade(TVS.java:156)
at com.objectdb.o.STA.Q(STA.java:476)
at com.objectdb.o.STM.D(STM.java:390)
at com.objectdb.o.OBM.bJ(OBM.java:884)
at com.objectdb.jdo.PMImpl.bJ(PMImpl.java:2186)
at com.objectdb.o.OBM.bI(OBM.java:800)
at com.objectdb.o.OBM.bH(OBM.java:750)
at com.objectdb.o.QRR.b(QRR.java:137)
at com.objectdb.o.QRR.b(QRR.java:634)
at com.objectdb.o.UMR.u(UMR.java:501)
at com.objectdb.o.ENT.loadInverse(ENT.java:1284)
at com.objectdb.o.IVP.h(IVP.java:100)
at com.objectdb.o.IVP.g(IVP.java:87)
at com.objectdb.o.ISP.size(ISP.java:152)
at com.objectdb.o.CLT.visitRefs(CLT.java:156)
at com.objectdb.o.TVS.j(TVS.java:169)
at com.objectdb.o.TVS.cascade(TVS.java:156)
at com.objectdb.o.STA.Q(STA.java:476)
at com.objectdb.o.STM.D(STM.java:390)
at com.objectdb.o.OBM.bJ(OBM.java:884)
at com.objectdb.jdo.PMImpl.bJ(PMImpl.java:2186)
at com.objectdb.o.OBM.bI(OBM.java:800)
at com.objectdb.o.OBM.bH(OBM.java:750)
at com.objectdb.o.QRR.b(QRR.java:137)
at com.objectdb.o.QRR.b(QRR.java:634)
at com.objectdb.o.UMR.u(UMR.java:501)
at com.objectdb.o.ENT.loadInverse(ENT.java:1284)
at com.objectdb.o.IVP.h(IVP.java:100)
at com.objectdb.o.IVP.g(IVP.java:87)
at com.objectdb.o.IMP.values(IMP.java:153)
at java.util.Collections$UnmodifiableMap.values(Collections.java:1315)
at com.aqera.domains.one.activities.Aqera.z_getRegister(Aqera.java:152)
at com.aqera.domains.one.activities.Aqera.getRegister(Aqera.java:169)
at com.aqera.domains.one.simulator.datatypes.peopleandorgs.PersonActivity.z_registerPerson(PersonActivity.java:255)
at com.aqera.domains.one.simulator.datatypes.peopleandorgs.PersonActivity.registerPerson(PersonActivity.java:320)
at com.aqera.domains.one.simulator.datatypes.peopleandorgs.PeopleAndOrgData.z_load(PeopleAndOrgData.java:396)
at com.aqera.domains.one.simulator.datatypes.peopleandorgs.PeopleAndOrgData.load(PeopleAndOrgData.java:476)
at com.aqera.domains.one.simulator.SimulationWorkbook.z_go(SimulationWorkbook.java:286)
at com.aqera.domains.one.simulator.SimulationWorkbook.go(SimulationWorkbook.java:305)
at com.aqera.domains.one.scheduling.ScheduledActivity.z_run(ScheduledActivity.java:507)
at com.aqera.domains.one.scheduling.ScheduledActivity.run(ScheduledActivity.java:547)
at com.aqera.domains.one.scheduling.ScheduleActivityRun.z_run(ScheduleActivityRun.java:260)
at com.aqera.domains.one.scheduling.ScheduleActivityRun.run(ScheduleActivityRun.java:267)
at com.aqera.domains.one.scheduling.ScheduledActivityControl.z_runNextDay(ScheduledActivityControl.java:361)
at com.aqera.domains.one.scheduling.ScheduledActivityControl.runNextDay(ScheduledActivityControl.java:374)
at com.aqera.domains.one.simulator.SimulationSingleton.z_moveUpToActual(SimulationSingleton.java:1952)
at com.aqera.domains.one.simulator.SimulationSingleton.moveUpToActual(SimulationSingleton.java:1963)
at com.aqera.domains.one.simulator.SimulationTxnController.execute_MoveUpToActual(SimulationTxnController.java:307)
at com.aqera.domains.one.simulator.SimulationTxnController.execute_D1(SimulationTxnController.java:340)
at com.aqera.domains.one.simulator.SimulationTxnController.execute_M2(SimulationTxnController.java:285)
at com.aqera.domains.one.simulator.SimulationTxnController.end_Waiting(SimulationTxnController.java:359)
at com.aqera.domains.one.simulator.SimulationTxnController.receiveEvent_Run(SimulationTxnController.java:225)
at com.aqera.domains.one.simulator.SimulationTxnController.generateCallEvent(SimulationTxnController.java:206)
at com.aqera.domains.one.simulator.SimulationTxnController.moveUpTo(SimulationTxnController.java:149)
at com.aqera.domains.one.simulator.SimulationSingleton.z_moveUpTo(SimulationSingleton.java:787)
at com.aqera.domains.one.simulator.SimulationSingleton.moveUpTo(SimulationSingleton.java:795)
at com.aqera.domains.one.tests.SimulatorTest.testScheduleWorkbook(SimulatorTest.java:101)
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 junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at com.aqera.domains.one.tests.SimulatorTest.runBare(SimulatorTest.java:34)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at com.aqera.domains.one.tests.SimulatorTestSuite$1.run(SimulatorTestSuite.java:60)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
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)

 

As before a Map structure was being accessed.

@OneToMany(cascade=CascadeType.ALL, mappedBy="z_aqera")
@MapKey(name="z_registerId")
    private java.util.Map<java.lang.String, com.aqera.domains.one.activities.AqeraRegister> z_registers  = new java.util.HashMap<java.lang.String, com.aqera.domains.one.activities.AqeraRegister>();

As before Enhancer is being run on code before test runs.

Thanks again.

#5

The Maven project that causes this exception could help.

ObjectDB Support
#6

Sorry for the delay. We are seeing if we can make the thing any smaller.

#7

We have spent some time tracking this down.

If we do not do static enhancing we do not get this bug.

The uploaded zip contains a maven project (  its also an Eclipse project ) which you can use to replicate the bug. We chose to use maven because of the static weaving step.

#8

Thank you for the test case. Build 2.2.3_05 should fix the problem.

ObjectDB Support

Reply