1 Reply Latest reply on Apr 10, 2012 2:54 AM by Linh Pham

    StaleObjectStateException on jBPM 5.1 running on JBoss 6.1

    Linh Pham Newbie

      Hi All,

       

      I got an intermittent StaleObjectStateException while completing a Human Task in jBPM. My current set up is as follows:

      - Message Driven Bean processes a message, and invokes jBPM to complete a human task:

       

          @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW)

          public void onMessage(Message message)

          {

              try

              {

                     // pulling out the sessionId, workItemId, and resultsMap  from the message

                  final StatefulKnowledgeSession ksession = ((JbpmLauncher) new InitialContext().lookup("java:module/JbpmLauncher")).getSession(sessionId);

                  ksession.getWorkItemManager().completeWorkItem(inbound.getWorkItemId(), inbound.getResultsMap());

              }

              catch(NamingException e)

              {

                  LOGGER.error("Encounterred exception", e);

                  throw new WorkflowException("Unable to find the JBPM Launcher. ", e);    //WorkflowException is RuntimeException with @ApplicationException annotation.

              }

              catch(Exception e)

              {

                  LOGGER.error("Encounterred exception", e);

                  throw new WorkflowException(e);   //WorkflowException is RuntimeException with @ApplicationException annotation.

              }

          }

       

      Intermittently, I got StaleObjectStateException and the stack trace is here: http://pastebin.com/HxUfSPh5

       

      I am using jBPM 5.1, JBoss 6.1, the jbpm-ds.xml is XA datasource with transaction isolation of TRANSACTION_READ_COMMITTED.  JMS implementation is ActiveMQ with XA Datasource.

      My environment is very low traffic, with just one user doing testing at the moment.

       

      Is there a way to reliably reproduce the problem? And more importantly how can I get around this StaleObjectStateException?

       

      Thanks for your help.

       

      Linh

        • 1. Re: StaleObjectStateException on jBPM 5.1 running on JBoss 6.1
          Linh Pham Newbie

          I have found out that the transaction annoation for my MDB was wrong. It should be using TransactionAttributeType.REQUIRED instead of REQUIRES_NEW.  I also double check all datasource configurations to make sure they are XA transactions.  With @ApplicationException, the default for rollback is FALSE, make sure it is TRUE so that the transaction can be rolledback and retried when exception occurs.

           

          Having done all of the above, my transactions indeed retried and it was processed successfully upon retry.  To minimise the possibility of StaleObjectStateException, I invoke ksession.dispose() at the end after complete using ksession.

           

          Hope this helps.

           

          -- Linh