583 words

Issue #78 - NullPointer when accessing persistent field

BugVersion: 2.3.2Priority: NormalStatus: FixedReplies: 7
#1
2011-10-25 18:39

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

 

JFK
JFK's picture
Joined on 2011-08-24
User Post #18
#2
2011-10-26 00:30

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 I78 {
 
    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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #676
#3
2011-10-26 09:42

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.

JFK
JFK's picture
Joined on 2011-08-24
User Post #19
#4
2011-10-26 09:56

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.

JFK
JFK's picture
Joined on 2011-08-24
User Post #20
#5
2011-10-26 10:05

The Maven project that causes this exception could help.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #679
#6
2011-10-26 14:01

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

JFK
JFK's picture
Joined on 2011-08-24
User Post #21
#7
2011-11-04 16:58

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.

JFK
JFK's picture
Joined on 2011-08-24
User Post #22
#8
2011-11-06 19:23

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

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #696

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Attachments:
Maximum file size: 32 MB
Cancel