OpenJPA
  1. OpenJPA
  2. OPENJPA-752

ProxySetupStateManager.setProxyData routing through PersistanceCapable caused "PersistenceException: null"

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.3, 1.1.0, 1.2.0, 1.3.0
    • Fix Version/s: 1.0.4, 1.2.1, 1.3.0, 2.0.0-M2
    • Component/s: kernel
    • Labels:
      None

      Description

      The symptom of the problem is an InternalException is thrown from ProxySetupStateManager.provide*Field method due to mismatched routing to a PersistenceCapable object: The stack will look like something similar to this:

      Exception in thread "main" <openjpa-1.0.3-SNAPSHOT-r420667:649224M fatal user error> org.apache.openjpa.persistence.ArgumentException: Errors encountered while resolving metadata. See nested exceptions for details.
      at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:522)
      at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:302)
      at org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1060)
      at org.apache.openjpa.kernel.DelegatingBroker.newObjectId(DelegatingBroker.java:252)
      at org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:347)
      at test.Main.main(Main.java:16)
      Caused by: <openjpa-1.0.3-SNAPSHOT-r420667:649224M fatal general error> org.apache.openjpa.persistence.PersistenceException: null
      at org.apache.openjpa.meta.ProxySetupStateManager.providedBooleanField(ProxySetupStateManager.java:206)
      at test.BaseNonVersionEntity.pcProvideField(BaseNonVersionEntity.java)
      at test.BaseVersionEntity.pcProvideField(BaseVersionEntity.java)
      at test.EntityVersionedA.pcProvideField(EntityVersionedA.java)
      at org.apache.openjpa.meta.ProxySetupStateManager.setProxyData(ProxySetupStateManager.java:62)
      at org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1731)
      at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1613)
      at org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:675)
      at org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:575)
      at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:500)
      ... 5 more
      NestedThrowables:
      <openjpa-1.0.3-SNAPSHOT-r420667:649224M fatal user error> org.apache.openjpa.persistence.ArgumentException: Unable to resolve type "test.EntityNonVersionedM" due to previous errors resolving related type "test.EntityVersionedA".
      at org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:689)
      at org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:575)
      at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:500)
      at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:302)
      at org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1060)
      at org.apache.openjpa.kernel.DelegatingBroker.newObjectId(DelegatingBroker.java:252)
      at org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:347)
      at test.Main.main(Main.java:16)

      I shall attach a test case later.

      Albert Lee.

        Activity

        Hide
        Albert Lee added a comment -

        The use case is:

        • An entity inherits from 2 nested super classes
          EntityVersionedA -> BaseVersionEntity -> BaseNonVersionEntity
        • The entities are packaged in 2 different jar files
        • The persistence.xml reference one of the jar file in the persistence unit's <jar-file>

        Since not all entities are packaged in the same jar file, resolving metadata of these class hierarchy do not build correctly in the ClassMetaData's attribue "_allFields". This field contains fewer number of attributes in the corresponding persistence capable class. However the enhancer was able to detect all the fields based of Reflection, hence there is a mis-matched attribute table list between the ClassMetaData and the enhanced class. As a result, the interaction between the ProxySetupStateManager and the PersistenceCapable class route the method call to the wrong indexed provide*Field method.

        This problem may only occur if there is Calendar, Collection or Map object defined in an entity.

        The cause of the exception is basically incorrect packaging, a better exception message will go a long way to help application to correct the problem.

        Albert Lee.

        Show
        Albert Lee added a comment - The use case is: An entity inherits from 2 nested super classes EntityVersionedA -> BaseVersionEntity -> BaseNonVersionEntity The entities are packaged in 2 different jar files The persistence.xml reference one of the jar file in the persistence unit's <jar-file> Since not all entities are packaged in the same jar file, resolving metadata of these class hierarchy do not build correctly in the ClassMetaData's attribue "_allFields". This field contains fewer number of attributes in the corresponding persistence capable class. However the enhancer was able to detect all the fields based of Reflection, hence there is a mis-matched attribute table list between the ClassMetaData and the enhanced class. As a result, the interaction between the ProxySetupStateManager and the PersistenceCapable class route the method call to the wrong indexed provide*Field method. This problem may only occur if there is Calendar, Collection or Map object defined in an entity. The cause of the exception is basically incorrect packaging, a better exception message will go a long way to help application to correct the problem. Albert Lee.
        Hide
        Albert Lee added a comment -

        Test case to reproduce the problem.

        Show
        Albert Lee added a comment - Test case to reproduce the problem.

          People

          • Assignee:
            Albert Lee
            Reporter:
            Albert Lee
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development