glassfish
  1. glassfish
  2. GLASSFISH-635

Toplink's VersionLockingPolicy became to throw a NullPointerException

    Details

    • Issuezilla Id:
      635

      Description

      From (at latest) B46, Toplink's VersionLockingPolicy class became to throw a
      NullPointerException in a certain point of my application with (probablly)
      EntityManager.flush().

      The application codes worked with B36 and not modified since it worked
      (persistence.xml is modified to suite spec changes between B36 and B46). I
      recognized this problem with B46, and B47 still has this problem. This issue
      prevents my application from working and I don't find a workaround for this
      yet. The stacktrace is as follows:
      ======
      Caused by: java.lang.NullPointerException
      at
      oracle.toplink.essentials.descriptors.VersionLockingPolicy.compareWriteLockValue
      s(VersionLockingPolicy.java:185)
      at
      oracle.toplink.essentials.internal.sessions.ObjectChangeSet.mergeObjectChanges
      (ObjectChangeSet.java:562)
      at
      oracle.toplink.essentials.internal.sessions.UnitOfWorkChangeSet.mergeObjectChang
      es(UnitOfWorkChangeSet.java:377)
      at
      oracle.toplink.essentials.internal.sessions.UnitOfWorkChangeSet.mergeUnitOfWorkC
      hangeSet(UnitOfWorkChangeSet.java:397)
      at
      oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.write
      Changes(RepeatableWriteUnitOfWork.java:255)
      at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.flush
      (EntityManagerImpl.java:268)
      at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.performFlush
      (EJBQueryImpl.java:682)
      at
      oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.executeReadQuery
      (EJBQueryImpl.java:333)
      at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.getResultList
      (EJBQueryImpl.java:430)
      at my.package.control.MySessionBeanImpl.findFooByDate
      (MySessionBeanImpl.java:701)
      at my.package.control.MySessionBeanImpl.myBusinessLogic
      (MySessionBeanImpl.java:600)
      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:585)
      at com.sun.enterprise.security.application.EJBSecurityManager.runMethod
      (EJBSecurityManager.java:1050)
      at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:165)
      at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod
      (BaseContainer.java:2766)
      at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3847)
      at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke
      (EJBObjectInvocationHandler.java:190)
      ... 17 more
      ======

      I encountered the same exception in another place in my application with B44.
      This is disappeared since B46, without modification with my application's codes.
      ======
      Caused by: java.lang.NullPointerException
      at
      oracle.toplink.essentials.descriptors.VersionLockingPolicy.compareWriteLockValue
      s(VersionLockingPolicy.java:185)
      at
      oracle.toplink.essentials.internal.sessions.ObjectChangeSet.mergeObjectChanges
      (ObjectChangeSet.java:562)
      at
      oracle.toplink.essentials.internal.sessions.UnitOfWorkChangeSet.mergeObjectChang
      es(UnitOfWorkChangeSet.java:377)
      at
      oracle.toplink.essentials.internal.sessions.UnitOfWorkChangeSet.mergeUnitOfWorkC
      hangeSet(UnitOfWorkChangeSet.java:397)
      at
      oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.write
      Changes(RepeatableWriteUnitOfWork.java:255)
      at
      oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.flush
      (EntityManagerImpl.java:268)
      at com.sun.enterprise.util.EntityManagerWrapper.flush
      (EntityManagerWrapper.java:509)
      at my.package.control.EntityManagerWrapper.flush
      (EntityManagerWrapper.java:129)
      at
      my.package.control.JournalRecordManager.updateQuarterlyBalance
      (JournalRecordManager.java:401)
      at my.package.control.JournalRecordManager.onEpisodeModified
      (JournalRecordManager.java:63)
      at my.package.control.EditProgramControlImpl.createEpisode
      (EditProgramControlImpl.java:283)
      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:585)
      at
      com.sun.enterprise.security.application.EJBSecurityManager.runMethod
      (EJBSecurityManager.java:1050)
      at com.sun.enterprise.security.SecurityUtil.invoke
      (SecurityUtil.java:165)
      at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod
      (BaseContainer.java:2766)
      at com.sun.ejb.containers.BaseContainer.intercept
      (BaseContainer.java:3847)
      at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke
      (EJBObjectInvocationHandler.java:190)
      ... 17 more
      ======

      See the GlassFish forum for additional information :
      http://forums.java.net/jive/thread.jspa?threadID=15041&tstart=15

        Activity

        Hide
        mf125085 added a comment -

        Created an attachment (id=273)
        testcase, unjar under entity-persistence-tests

        Show
        mf125085 added a comment - Created an attachment (id=273) testcase, unjar under entity-persistence-tests
        Hide
        mf125085 added a comment -

        To run the test, please unjar issue635.jar under entity-persistence-tests. Then
        run the newly created

        oracle.toplink.essentials.testing.tests.cmp3.advanced.EntityMappingsAdvancedJUnitTestCase

        Junit test. The situation is:

        An Employee is persisted, and in the same transaction two previously created
        Projects are added to the Employee. The NullPointerException happens at the
        second commit.

        Show
        mf125085 added a comment - To run the test, please unjar issue635.jar under entity-persistence-tests. Then run the newly created oracle.toplink.essentials.testing.tests.cmp3.advanced.EntityMappingsAdvancedJUnitTestCase Junit test. The situation is: An Employee is persisted, and in the same transaction two previously created Projects are added to the Employee. The NullPointerException happens at the second commit.
        Hide
        mf125085 added a comment -

        Be aware that issue635.jar contains Employee and Project classes also used by
        other entity-persistence tests. I changed the version field in above classes to
        be of type Integer.

        Show
        mf125085 added a comment - Be aware that issue635.jar contains Employee and Project classes also used by other entity-persistence tests. I changed the version field in above classes to be of type Integer.
        Hide
        mf125085 added a comment -

        For instances having an Object typed version field, e.g. Integer, a
        NullPointerException might be thrown when comparing versions in
        ObjectChangeSet#compareWriteLockValues.
        Added a new method setting the initialWriteLockValue in ObjectChangeSet, which
        is called when an object is first inserted to the database in
        VersionLockingPolicy#setupWriteFieldsForInsert. This makes sure, that the value
        initialWriteLockValue is always set, thereby preventing the NullPointerException.

        The fix is checked in into the trunk:
        http://fisheye5.cenqua.com/changelog/glassfish/?cs=MAIN:mf125085:20060609190609

        Show
        mf125085 added a comment - For instances having an Object typed version field, e.g. Integer, a NullPointerException might be thrown when comparing versions in ObjectChangeSet#compareWriteLockValues. Added a new method setting the initialWriteLockValue in ObjectChangeSet, which is called when an object is first inserted to the database in VersionLockingPolicy#setupWriteFieldsForInsert. This makes sure, that the value initialWriteLockValue is always set, thereby preventing the NullPointerException. The fix is checked in into the trunk: http://fisheye5.cenqua.com/changelog/glassfish/?cs=MAIN:mf125085:20060609190609
        Hide
        mf125085 added a comment -

        Updated target milestone.

        Show
        mf125085 added a comment - Updated target milestone.

          People

          • Assignee:
            mf125085
            Reporter:
            isana
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: