3 Replies Latest reply on Aug 26, 2008 9:40 AM by kbhatt_81

    JBAS 4.0.3SP1 and EJB3 RC6 (NPE)

    dbudworth

      We just upgraded to EJB3 RC6 and are now getting NPEs in
      org.hibernate.persister.entity.AbstractEntityPersister.lock(AbstractEntityPersister.java:1282)

      This occurs while calling em.lock(obj)

      adding debugging to our code, we have verified that "obj" is not null, so we're not sure whats going on (worked fine with RC5)

      Is there a place to get exact source for RC6? It could easily be as simple as insufficient tags on the class now, but we can't tell what line 1282 is trying to do to determine if that's the problem.

      More specifically, it's
      java.lang.NullPointerException
      at org.hibernate.persister.entity.AbstractEntityPersister.lock(AbstractEntityPersister.java:1282)
      at org.hibernate.event.def.AbstractLockUpgradeEventListener.upgradeLock(AbstractLockUpgradeEventListener.java:88)
      at org.hibernate.event.def.DefaultLockEventListener.onLock(DefaultLockEventListener.java:64)
      at org.hibernate.impl.SessionImpl.fireLock(SessionImpl.java:583)
      at org.hibernate.impl.SessionImpl.lock(SessionImpl.java:575)
      at org.hibernate.ejb.AbstractEntityManagerImpl.lock(AbstractEntityManagerImpl.java:341)
      at org.jboss.ejb3.entity.TransactionScopedEntityManager.lock(TransactionScopedEntityManager.java:101)

      And it occurs within a @Tx(TxType.REQUIRESNEW) (we don't use ejb3 transaction annotations since they don't take effect on internal calls in an ejb)

      Ideas?

        • 1. Re: JBAS 4.0.3SP1 and EJB3 RC6 (NPE)
          dbudworth

          Looking at fisheye (current rev, not sure which rev was RC6):

          Looks like AbstractEntityManager::lock(entity,LockModeType)
          calls getLockMode, which translates LockModeType.WRITE -> LockMode.FORCE

          But AbstractEntityPersister, who takes the Hib LockMode instance, has a static map of registered types which include READ, UPGRADE and UPGRADE_NOWAIT.

          It's missing FORCE

          So it gets the NPE. This is assuming we're looking at the right stuff (line numbers are definately wrong, but function signatures seem correct)

          So I suppose what I need is either source (to fix it), or suggestions on a work around (we need pesimistic locking in this code, and em.lock seems to be the only way to accomplish it)

          • 2. Re: JBAS 4.0.3SP1 and EJB3 RC6 (NPE)
            dbudworth

            Our workaround is to switch to LockModeType.READ
            which translates to LockMode.UPGRADE (which works)

            I suppose the LockModeType.WRITE -> LockMode.FORCE thing is just a plain old bug? (since hibernate 3.1 AND 3.2CR1 both don't actually support FORCE, same issue in the static map)

            • 3. Re: JBAS 4.0.3SP1 and EJB3 RC6 (NPE)
              kbhatt_81

              Hi I am also facing same problem..

              I have also checked my code and object we are passing to lock is not null but still we are getting same exception.

              The below line is creating exception where em is EntityManager Object.

              em.lock(vehicle, LockModeType.WRITE);

              Please send any hint to solve this.

              Thanks

              Krunal Bhatt