glassfish
  1. glassfish
  2. GLASSFISH-123

flush in Extended Persistence Context does not work

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 9.0pe
    • Fix Version/s: 9.0pe
    • Component/s: entity-persistence
    • Labels:
      None
    • Environment:

      Operating System: Windows XP
      Platform: PC

    • Issuezilla Id:
      123

      Description

      A stateful session bean with an extended persistence context does not update
      data in any but the very first method invocation. Looking at the TopLink
      log output, it seems the unit of work is released immediately after the
      first method rather than maintained. This observation is confirmed by the
      fact the calls to entitymanager.flush() lead to a TopLink exception:

      Exception [TOPLINK-6027] (Oracle TopLink Essentials - 10g release 4 (10.1.4.0.0)
      (Build 051215Dev)): oracle.toplink.essentials.exceptions.QueryException
      Exception Description: Query sent to a unactivated UnitOfWork.
      Query: UpdateObjectQuery(Acc.# 4444, owneranonymous, balance: 300 $)
      at
      oracle.toplink.essentials.exceptions.QueryException.querySentToInactiveUnitOfWork(QueryException.java:870)

      The annotations on the stateful session beans are:

      @Stateful
      @Remote(AccountInterface.class)
      public class AccountBean implements AccountInterface {
      @PersistenceContext(type=PersistenceContextType.EXTENDED, unitName="intro")
      private EntityManager manager;

      /* this method is called at some point and fails with the flush()
      call, or does not update data without it */
      @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
      public void deposit(int amount)

      { if(account==null) throw new IllegalStateException(); account.deposit(amount); manager.flush(); }

      ...

        Activity

        Hide
        marina vatkina added a comment -

        Hmmm... interesting... now I do get an exception, but an NPE:

        java.lang.NullPointerException
        at
        oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.executeCall(UnitOfWorkImpl.java:1339)
        at
        oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:213)
        at
        oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:199)
        at
        oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.updateObject(DatasourceCallQueryMechanism.java:684)
        at
        oracle.toplink.essentials.internal.queryframework.StatementQueryMechanism.updateObject(StatementQueryMechanism.java:439)
        at
        oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:1166)
        at
        oracle.toplink.essentials.queryframework.UpdateObjectQuery.executeCommitWithChangeSet(UpdateObjectQuery.java:76)
        at
        oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:283)
        at
        oracle.toplink.essentials.queryframework.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:67)
        at
        oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:609)
        at
        oracle.toplink.essentials.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:536)
        at
        oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:123)
        at
        oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:95)
        at
        oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2194)
        at
        oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:937)
        at
        oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:894)
        at
        oracle.toplink.essentials.internal.sessions.CommitManager.commitChangedObjectsForClassWithChangeSet(CommitManager.java:294)
        at
        oracle.toplink.essentials.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:180)
        at
        oracle.toplink.essentials.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:2625)
        at
        oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1007)
        at
        oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:353)
        at
        oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithPreBuiltChangeSet(UnitOfWorkImpl.java:1123)
        at
        oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.writeChanges(RepeatableWriteUnitOfWork.java:231)
        at
        oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.flush(EntityManagerImpl.java:268)
        at
        com.sun.enterprise.util.EntityManagerWrapper.flush(EntityManagerWrapper.java:255)
        at example.ejb.impl.AccountManagerImpl.deposit(Unknown Source)

        Reassigning to Tom as it was working the last time I tried. I'll attach the test
        case that is a slight modification of Sahoo's version.

        Show
        marina vatkina added a comment - Hmmm... interesting... now I do get an exception, but an NPE: java.lang.NullPointerException at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.executeCall(UnitOfWorkImpl.java:1339) at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:213) at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:199) at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.updateObject(DatasourceCallQueryMechanism.java:684) at oracle.toplink.essentials.internal.queryframework.StatementQueryMechanism.updateObject(StatementQueryMechanism.java:439) at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:1166) at oracle.toplink.essentials.queryframework.UpdateObjectQuery.executeCommitWithChangeSet(UpdateObjectQuery.java:76) at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:283) at oracle.toplink.essentials.queryframework.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:67) at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:609) at oracle.toplink.essentials.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:536) at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:123) at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:95) at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2194) at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:937) at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:894) at oracle.toplink.essentials.internal.sessions.CommitManager.commitChangedObjectsForClassWithChangeSet(CommitManager.java:294) at oracle.toplink.essentials.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:180) at oracle.toplink.essentials.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:2625) at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1007) at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:353) at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithPreBuiltChangeSet(UnitOfWorkImpl.java:1123) at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.writeChanges(RepeatableWriteUnitOfWork.java:231) at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.flush(EntityManagerImpl.java:268) at com.sun.enterprise.util.EntityManagerWrapper.flush(EntityManagerWrapper.java:255) at example.ejb.impl.AccountManagerImpl.deposit(Unknown Source) Reassigning to Tom as it was working the last time I tried. I'll attach the test case that is a slight modification of Sahoo's version.
        Hide
        marina vatkina added a comment -

        Created an attachment (id=136)
        test case that throws NPE - see README for the steps

        Show
        marina vatkina added a comment - Created an attachment (id=136) test case that throws NPE - see README for the steps
        Hide
        marina vatkina added a comment -

        ...

        Show
        marina vatkina added a comment - ...
        Hide
        pkrogh added a comment -

        This was fixed and checked into CVS on the weekend.

        Show
        pkrogh added a comment - This was fixed and checked into CVS on the weekend.
        Hide
        shanchen added a comment -
            • Issue 443 has been marked as a duplicate of this issue. ***
        Show
        shanchen added a comment - Issue 443 has been marked as a duplicate of this issue. ***

          People

          • Assignee:
            tware
            Reporter:
            gbrose
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: