0 Replies Latest reply on Feb 8, 2010 6:13 AM by Andrius Miasnikovas

    Using timers when integrating jBPM4.2 with Spring 2.5.6

    Andrius Miasnikovas Newbie



      I'm using JDK and integrated jBPM 4.2 with Spring  2.5.6 in a web application that runs on Liferay portal. JBPM tables are in the same database with the tables for the application domain. The user influences the process by interacting with the application and when my service layer gets called Spring annotated service methods propagate the transaction and jbpm events become part of the transaction and either everything goes well or everything gets rolled back. Also the jbpm event implementations have access to the dao layer to modify the application domain. My problem is that some of the process states have timers with repeat attributes which aren't working well for me.


      <state name="do-something">
        <on event="timeout">
          <timer duedate="5 business seconds" repeat="5 business seconds" />
          <event-listener auto-wire="true" class="process.SomeEvent"/>
        <transition name="proceed" to="next-state"/>
        <transition name="giveup" to="fallback-state"/>


      The wayI understand it jobexecutor calls the timeout events at a later time in a newly created transaction. When I look at the logs I can see that the event executed and hibernated updated my domain objects in the database, but then some internal jbpm exception is thrown and the whole transaction gets rolled back. I've been at it for a few days now and can't understand what I'm doing wrong. Here's the configuration for the jbpm that I'm using


      <?xml version="1.0" encoding="UTF-8"?>


      <jbpm-configuration xmlns="http://jbpm.org/4.2/cfg">


              <repository-service />
              <repository-cache />
              <execution-service />
              <history-service />
              <management-service />
              <task-service />


              <script-manager default-expression-language="juel" default-script-language="juel" read-contexts="execution, environment, process-engine, spring" write-contexts="">
                  <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />


              <types resource="jbpm.variable.types.xml" />
              <address-resolver />


              <command-service name="txRequiredCommandService">
                  <skip-interceptor />
                  <retry-interceptor />
                  <environment-interceptor />


              <command-service name="newTxRequiredCommandService">
                  <retry-interceptor />
                  <environment-interceptor policy="requiresNew" />


              <job-executor command-service="newTxRequiredCommandService" />


              <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator">
                  <field name="commandService">
                      <ref object="newTxRequiredCommandService" />


              <object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />


                  <jpdl-deployer />


                  <monday    hours="7:00-20:00"/>
                  <tuesday   hours="7:00-20:00"/>
                  <wednesday hours="7:00-20:00"/>
                  <thursday  hours="7:00-20:00"/>
                  <friday    hours="7:00-20:00"/>


              <repository-session />
              <db-session />
              <message-session />
              <timer-session />
              <history-session />
                      <session-properties resource="jbpm.mail.properties" />
              <hibernate-session current="true" />




      Is there something wrong with it? Maybe I'm just not seeing straight anymore. The timer calls my event which does its work and then moves to another state which does something else and changes the database, I've been debugging what happens next and the jbpm's TimerImpl class checks if repeat attirbute is set (in my case - it is) schedules a new due date, releases the lock on the timer and executes the following code


      JobExecutor jobExecutor = environment.get(JobExecutor.class);
            if (jobExecutor!=null) {
              Transaction transaction = environment.get(Transaction.class);
              if (transaction==null) {
                throw new JbpmException("no transaction in environment");



      here it fails to retrieve the new transaction and because it is null an exception is thrown and the transaction with all of my changes gets rolled back. It would seem that I'm misconfiguring something because the jobexecutor cannot retrieve the transaction but it did execute the event. Did someone ran into something similar or knows how to fix this?