9 Replies Latest reply on Oct 17, 2009 1:16 PM by aapthorp

    superstate timer error

    aapthorp

      I have a process definition which includes a couple of timers; one on a state and another on a superstate. The timer on the state works as expected. However, when my process reaches the superstate it throws a StaleObjectStateException. Also, the timer seems to execute, but for each of the superstate's sub states as well as the superstate. Each time the timer repeats I see the same error.

      I've looked around the forum / Jira amd can't see that anyone else has observed this problem.

      My process definition is as follows:

      <state name="State 1">
       <timer duedate="20 seconds" repeat="20 seconds" name="late leaving">
       <script>
       System.out.println("What are we waiting for ? ");
       </script>
       </timer>
       <transition to="Moving" name="depart"></transition>
       </state>
      
       <super-state name="Moving">
       <state name="Stopped">
       <transition to="Started" name="start"></transition>
       </state>
       <state name="Started">
       <transition to="Stopped" name="stop"></transition>
       </state>
       <timer duedate="30 seconds" repeat="30 seconds">
       <script>
       System.out.println("We're late ");
       </script>
       </timer>
       <transition to="end-state1" name="arrive"></transition>
       </super-state>


      Produces the following:

      10:56:40,515 INFO [STDOUT] We're late
      10:56:40,562 INFO [STDOUT] We're late
      10:56:40,609 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
      org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.graph.exe.Token#578]
      at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1765)
      at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2407)
      at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2307)
      at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2607)
      at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
      at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)
      at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
      at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
      at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:59)
      at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
      at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)
      at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)
      at com.arjuna.ats.arjuna.AtomicAction.end(AtomicAction.java:216)
      at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commit(TransactionImple.java:240)
      at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:501)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:361)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)
      at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:527)
      at org.jboss.ejb.Container.invoke(Container.java:960)
      at org.jboss.ejb.txtimer.TimedObjectInvokerImpl.callTimeout(TimedObjectInvokerImpl.java:99)
      at org.jboss.ejb.txtimer.TimerImpl$TimerTaskImpl.run(TimerImpl.java:561)
      at java.util.TimerThread.mainLoop(Unknown Source)
      at java.util.TimerThread.run(Unknown Source)
      10:56:40,609 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@1a40ea6
      org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.graph.exe.Token#578]
      at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1765)
      at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2407)
      at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2307)
      at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2607)
      at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
      at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)
      at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
      at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
      at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:59)
      at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
      at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)
      at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)
      at com.arjuna.ats.arjuna.AtomicAction.end(AtomicAction.java:216)
      at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commit(TransactionImple.java:240)
      at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:501)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:361)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)
      at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:527)
      at org.jboss.ejb.Container.invoke(Container.java:960)
      at org.jboss.ejb.txtimer.TimedObjectInvokerImpl.callTimeout(TimedObjectInvokerImpl.java:99)
      at org.jboss.ejb.txtimer.TimerImpl$TimerTaskImpl.run(TimerImpl.java:561)
      at java.util.TimerThread.mainLoop(Unknown Source)
      at java.util.TimerThread.run(Unknown Source)
      10:56:40,609 ERROR [LogInterceptor] TransactionRolledbackLocalException in method: public abstract void javax.ejb.TimedObject.ejbTimeout(javax.ejb.Timer), causedBy:
      javax.transaction.RollbackException: [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] Can't commit because the transaction is in aborted state
      at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commit(TransactionImple.java:255)
      at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:501)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:361)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)
      at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:527)
      at org.jboss.ejb.Container.invoke(Container.java:960)
      at org.jboss.ejb.txtimer.TimedObjectInvokerImpl.callTimeout(TimedObjectInvokerImpl.java:99)
      at org.jboss.ejb.txtimer.TimerImpl$TimerTaskImpl.run(TimerImpl.java:561)
      at java.util.TimerThread.mainLoop(Unknown Source)
      at java.util.TimerThread.run(Unknown Source)
      Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.graph.exe.Token#578]
      at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1765)
      at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2407)
      at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2307)
      at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2607)
      at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
      at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)
      at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
      at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
      at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:59)
      at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
      at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)
      at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)
      at com.arjuna.ats.arjuna.AtomicAction.end(AtomicAction.java:216)
      at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commit(TransactionImple.java:240)
      ... 12 more
      10:56:40,609 ERROR [TimerImpl] Error invoking ejbTimeout: org.jboss.tm.JBossTransactionRolledbackLocalException: - nested throwable: (javax.transaction.RollbackException: [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] Can't commit because the transaction is in aborted state)
      10:56:40,781 INFO [STDOUT] We're late
      10:57:10,468 INFO [STDOUT] We're late
      10:57:10,578 INFO [STDOUT] We're late


        • 1. Re: superstate timer error
          aapthorp

          P.S. I'm using JBPM 3.3.0.GA, jboss 4.2.2.GA and HSQL

          • 2. Re: superstate timer error
            kukeltje

            3.3.0 == 3.2.5, 3.3.1 == 3.2.6. Have you tried the latest version already (keep in mind that the 3.3 branch was dropped)

            • 3. Re: superstate timer error
              aapthorp

              Thanks, will give it a try...too busy with other things and had missed this change...

              • 4. Re: superstate timer error
                aapthorp

                Hmm, same problem.

                Also, I had to change the datasource configuration in

                ..\jboss-4.2.3.GA\server\default\deploy\ejb-deployer.xml

                and

                ..\jboss-4.2.3.GA\server\default\deploy\jbpm\jbpm-enterprise.jar\META-INF\jbosscmp-jdbc.xml

                from DefaultDS to JbpmDS otherwise I got a JDBC connection failure on the first timer.

                • 5. Re: superstate timer error
                  kukeltje

                  Your last two remarks are not jBPM specific. jBPM 3 uses EJB timers by default and they use the DefaultDS since they are not jbpm specifc. (you need a DefaultDS to for JMS etc...

                  Not sure though if this has changed in 3.2(.7) trunk.

                  And there have been some other changes regarding db stuff in the latest trunk (which is 3.2 based since 3.3 has been dropped)

                  • 6. Re: superstate timer error
                    aapthorp

                    Hmm, clearly need to look more closely at my JBoss config. I just tried the same process definition on an old JBPM 3.2.2 install on Jboss 4.0.2. No exception is thrown but the timer action (i.e. the output message) still gets executed twice each time the superstate timer expires. I presume this is the wrong behaviour?

                    • 7. Re: superstate timer error
                      kukeltje

                      Sounds like the wrong behaviour, but that might be a configuration issue as well e.g. two jobexecutors

                      • 8. Re: superstate timer error
                        aapthorp

                        Banging my head against this one...

                        "aapthorp" wrote:
                        Hmm, same problem.

                        Also, I had to change the datasource configuration in

                        ..\jboss-4.2.3.GA\server\default\deploy\ejb-deployer.xml



                        Have changed the ejb-deployer config as per the following

                        http://www.jboss.org/index.html?module=bb&op=viewtopic&t=147824

                        This at least gets over the connection failure exception as mentioned in the referenced thread. I assume this is correct...

                        • 9. Re: superstate timer error
                          aapthorp

                          Testing now on 3.2.6.SP1

                          A bit more digging and I think I'm closer to the problem. It seems the problem is to do with setting a timer on a superstate. I reduced my superstate definition down to one state within the superstate and still the problem occurs.

                          When I replace the superstate with just a normal state then no problem.

                          This seems similar to https://jira.jboss.org/jira/browse/JBPM-2036. Will make a comment there but think this is a separate issue.