Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-1892

NullPointerException thrown by the BrokerImpl.find() if requesting an entity which is marked by the @Cacheable(false) annotation

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0.0, 2.1.0
    • 2.1.0
    • datacache
    • None
    • OpenJPA 2.0.0
      PostgreSQL 8.4
      Application managed env

    Description

      The configuration is as follows:
      1. We have two entities which are in parent-child relationship (class Parent, class Child extends Parent)
      2. The child entity is marked by the @Cacheable(false) annotation
      3. The parent entity is not marked by the @Cacheable annotation
      4. Shared cache configuration is set to DISABLE_SELECTIVE
      5. Transaction type is RESOURCE_LOCAL

      The test case is:
      1. Create an instance of the Child entity and set some properties
      2. Persist the entity by calling the EntityManager.persist() method
      3. Request the entity using EntityManager.find() method and make sure the returned instance is the same which been persisted.
      4. Clear L1 cache usign EntityManager.clear() mwthod
      5. Repeat step 3. Here we get NPE in the BrokerImpl.find()

      <openjpa-2.0.0-r422266:935683 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: null
      FailedObject: 2051 [org.apache.openjpa.util.StringId] [java.lang.String]
      at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:986)
      at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:880)
      at org.apache.openjpa.kernel.DelegatingBroker.find(DelegatingBroker.java:223)
      at org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:476)
      at test.openjpa.caching.TestOpenJPACacheable.test(TestOpenJPACacheable.java:55)
      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:44)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
      at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
      at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
      at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
      at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
      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.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
      at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
      Caused by: java.lang.NullPointerException
      at org.apache.openjpa.datacache.DataCacheStoreManager.newPCData(DataCacheStoreManager.java:670)
      at org.apache.openjpa.datacache.DataCacheStoreManager.cacheStateManager(DataCacheStoreManager.java:374)
      at org.apache.openjpa.datacache.DataCacheStoreManager.initialize(DataCacheStoreManager.java:353)
      at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:112)
      at org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
      at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:1005)
      at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:963)
      ... 32 more

      Attachments

        1. jpa-cache.zip
          6 kB
          Nik Maximov

        Activity

          jwrap Nik Maximov added a comment -

          The test case attached.
          NOTE: In case if parent entity also marked as non-cacheable all works.

          jwrap Nik Maximov added a comment - The test case attached. NOTE: In case if parent entity also marked as non-cacheable all works.

          Committed a test and code change to trunk.

          @see revision 1036988.

          Rick

          curtisr7 Richard G. Curtis added a comment - Committed a test and code change to trunk. @see revision 1036988. Rick

          People

            curtisr7 Richard G. Curtis
            jwrap Nik Maximov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: