2 Replies Latest reply on Dec 14, 2006 9:31 AM by Jim Knopf

    Failure when ending process

    jrojas_pb Newbie

      Hi,

      I have a process that loops to a wait state. The wait state uses a timer to perform a number of actions -- see process definition below. Everything runs fine until the Decision node determines that it is time for the process to end. The return("end-transition") eventually throws the exception shown below.

      The ProcessManager shown is where the process is started from, and once the process is started, it waits for the Decision node to raise a flag that the process is ending. The exception is thrown before the process.end() statement is called.

      I think I am not ending the process appropriately, and that it has to do with the timer. I tried cancelling the timer and suspending the timer, but either approach did not work. Should I be stopping the SchedulerThread? If so, how do I do that?

      Thanks in advance for your help!

      John


      HERE IS THE PROCESS DEFINITION:

      <?xml version="1.0" encoding="UTF-8"?>
      
      <process-definition
       xmlns="" name="Load Confirm Data Process">
       <start-state name="start">
       <transition name="" to="Wait For Start Time"></transition>
       </start-state>
       <state name="Wait For Start Time">
       <event type="node-enter">
       <action name="confirm-create-custom-timer-action" class="com.pb.mms.automation.ActionHandlers$CreateCustomTimerAction">
       <timerName>start-confirm-automated-tasks</timerName>
       <startTime></startTime>
       <dueDate>0 seconds</dueDate>
       <repeat>30 seconds</repeat>
       <transitionName>time-out-transition</transitionName>
      <!-- <actionName>FireTimerAction</actionName> -->
       </action>
       </event>
       <event type="node-leave">
       <action name="FireTimerAction" class='com.pb.mms.automation.ActionHandlers$FireTimerAction' />
       </event>
       <transition name="time-out-transition" to="fork1"></transition>
       </state>
       <fork name="fork1">
       <transition name="do-pkg-transition" to="Load PKG Files"></transition>
       <transition name="do-pts-transition" to="Load PTS Files"></transition>
       </fork>
       <node name="Load PKG Files">
       <event type="node-enter">
       <action name="load-pkg-files-action" class='com.pb.mms.automation.ActionHandlers$RunMmsServiceAction'>
       <serviceClass>test.com.pb.mms.bso.TestMmsService</serviceClass>
       <serviceArguments>
       <entry><key>dataSetName</key><value>Loadedpkg</value></entry>
       </serviceArguments>
       </action>
       </event>
       <transition name="" to="join1"></transition>
       </node>
       <node name="Load PTS Files">
       <event type="node-enter">
       <action name="load-pts-files-action" class='com.pb.mms.automation.ActionHandlers$RunMmsServiceAction'>
       <serviceClass>test.com.pb.mms.bso.TestMmsService</serviceClass>
       <serviceArguments>
       <entry><key>dataSetName</key><value>Loadedpts</value></entry>
       </serviceArguments>
       </action>
       </event>
       <transition name="" to="join1"></transition>
       </node>
       <join name="join1">
       <transition name="" to="Refresh Campaign Curves"></transition>
       </join>
       <node name="Refresh Campaign Curves">
       <event type="node-enter">
       <action name="refresh-campaign-curves-action" class='com.pb.mms.automation.ActionHandlers$RunMmsServiceAction'>
       <serviceClass>test.com.pb.mms.bso.TestMmsService</serviceClass>
       <serviceArguments>
       <entry><key>test variable</key><value>CurveCreationService</value></entry>
       </serviceArguments>
       </action>
       </event>
       <transition name="" to="Close Completed Campaigns"></transition>
       </node>
       <node name="Close Completed Campaigns">
       <event type="node-enter">
       <action name="close-completed-campaigns-action" class='com.pb.mms.automation.ActionHandlers$RunMmsServiceAction'>
       <serviceClass>test.com.pb.mms.bso.TestMmsService</serviceClass>
       <serviceArguments>
       <entry><key>test variable</key><value>CampaignCompletionService</value></entry>
       </serviceArguments>
       </action>
       </event>
       <transition name="" to="Refresh Completed Campaign Curves"></transition>
       </node>
       <decision name="Continue Or Shutdown">
       <handler class='com.pb.mms.automation.ActionHandlers$EndOrRepeatDecision' />
       <transition name="repeat-transition" to="Wait For Start Time"></transition>
       <transition name="end-transition" to="end1"></transition>
       </decision>
       <end-state name="end1"></end-state>
       <node name="Refresh Completed Campaign Curves">
       <event type="node-enter">
       <action name="refresh-completed-campaign-curves-action" class='com.pb.mms.automation.ActionHandlers$RunMmsServiceAction'>
       <serviceClass>test.com.pb.mms.bso.TestMmsService</serviceClass>
       <serviceArguments>
       <entry><key>test variable</key><value>CurveCreationService for completed campaigns</value></entry>
       </serviceArguments>
       </action>
       </event>
       <transition name="" to="Continue Or Shutdown"></transition>
       </node>
      </process-definition>
      


      HERE IS THE PROCESS MANAGER:
      package com.pb.mms.automation;
      
      
      import java.io.FileInputStream;
      
      import junit.framework.TestCase;
      
      import org.apache.log4j.Logger;
      import org.apache.log4j.PropertyConfigurator;
      import org.jbpm.JbpmConfiguration;
      import org.jbpm.JbpmContext;
      import org.jbpm.context.exe.ContextInstance;
      import org.jbpm.db.GraphSession;
      import org.jbpm.graph.def.ProcessDefinition;
      import org.jbpm.graph.exe.ProcessInstance;
      import org.jbpm.graph.exe.Token;
      import org.jbpm.scheduler.impl.SchedulerThread;
      
      
      /**
       * @author rojasjw
       *
       */
      public class ProcessManager extends TestCase
      {
      
       static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
      
       Logger logger = Logger.getLogger( ProcessManager.class );
      
      // static final String processName = "TimerTestProcess";
       static final String processName = "Load Confirm Data Process";
      
       static
       {
       // configure the logger
       PropertyConfigurator.configure("src/config.files/log4j.properties");
       }
      
      
       public void testProcess() throws Exception
       {
       deployProcessDefinition();
      
       long id = signalProcessToStart();
      
       runScheduler();
      
       waitForProcessToEnd( id );
       }
      
      
       /**
       *
       */
       private void deployProcessDefinition() throws Exception
       {
       JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
       try
       {
       // Deploy the process definition if not already deployed
       GraphSession graphSession = jbpmContext.getGraphSession();
       ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition( processName );
      // if( processDefinition == null )
      // {
       FileInputStream fis = new FileInputStream("processes/" + processName + "/processdefinition.xml");
       processDefinition = ProcessDefinition.parseXmlInputStream(fis);
      
       // Deploy the process definition in the database
       jbpmContext.deployProcessDefinition(processDefinition);
      // }
      
       assertNotNull( "Definition should not be null", processDefinition );
      
       }
       finally
       {
       jbpmContext.close();
       }
       }
      
      
       /**
       *
       */
       private long signalProcessToStart() throws Exception
       {
       // Lookup the pojo persistence context-builder that is configured above
       JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
       try
       {
       GraphSession graphSession = jbpmContext.getGraphSession();
      
       ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition( processName );
       assertNotNull( "Definition should not be null", processDefinition );
      
       // With the processDefinition that we retrieved from the database, we
       // can create an execution of the process definition just like in the
       // hello world example (which was without persistence).
       ProcessInstance processInstance = new ProcessInstance( processDefinition );
       assertNotNull( "Instance should not be null", processInstance );
      
       Token token = processInstance.getRootToken();
       assertEquals( "start", token.getNode().getName() );
      
       // Let's start the process execution
       token.signal();
      
       // Now the processInstance is saved in the database. So the
       // current state of the execution of the process is stored in the
       // database.
       jbpmContext.save( processInstance );
      
       return processInstance.getId();
       }
       finally
       {
       // Tear down the pojo persistence context.
       jbpmContext.close();
       }
       }
      
       /**
       *
       */
       private void waitForProcessToEnd( long id ) throws Exception
       {
       while( !processNeedsToEnd( id ) )
       {
       logger.info( "@@@@@@@@@@@@@@@@@@@@@@@ waiting for process to end......" );
      
       Thread.sleep( 20000 );
       }
      
       endProcess( id );
       }
      
      
       /**
       *
       */
       private boolean processNeedsToEnd( long id ) throws Exception
       {
       // Lookup the pojo persistence context-builder that is configured above
       JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
       try
       {
       GraphSession graphSession = jbpmContext.getGraphSession();
      
       // Use the process instance id to retrieve the process instance
       ProcessInstance processInstance = graphSession.loadProcessInstance( id );
      
       // See what state the process is in
       logger.info( "@@@@@@@@@@@@@@@@@@@@@@@ The processInstance=" + processInstance.getId() + " is in the following node: " + processInstance.getRootToken().getNode().getFullyQualifiedName() );
      
       ContextInstance contextInstance = (ContextInstance) processInstance.getInstance(ContextInstance.class);
      
       Object requestEndProcess = contextInstance.getVariable( "request-end-process" );
       if( requestEndProcess != null )
       return true;
       else
       return false;
       }
       finally
       {
       // Tear down the pojo persistence context.
       jbpmContext.close();
       }
       }
      
      
      
       /**
       * THIS METHOD IS NEVER CALLED
       */
       private void endProcess( long id ) throws Exception
       {
      
       // Lookup the pojo persistence context-builder that is configured above
       JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
       try
       {
       GraphSession graphSession = jbpmContext.getGraphSession();
      
       // Use the process instance id to retrieve the process instance
       ProcessInstance processInstance = graphSession.loadProcessInstance( id );
      
       // See what state the process is in
       logger.info( "@@@@@@@@@@@@@@@@@@@@@@@ The processInstance=" + processInstance.getId()
       + " is in the following node: " + processInstance.getRootToken().getNode().getFullyQualifiedName() );
      
       // THE EXCEPTION OCCURS BEFORE THIS POINT
       // end the process --
       while( !processInstance.hasEnded() )
       processInstance.end();
      
       logger.info( "@@@@@@@@@@@@@@@@@@@@@@@ The processInstance=" + processInstance.getId() + " : "
       + processInstance.getProcessDefinition().getName() + " HAS ENDED" );
      
       // Now the processInstance is saved in the database. So the
       // current state of the execution of the process is stored in the
       // database.
       logger.info( "@@@@@@@@@@@@@@@@@@@@@@@ Saving the ended processInstance=" + processInstance.getId() + " : " + processInstance.getProcessDefinition().getName() );
       jbpmContext.save( processInstance );
       // The method below will get the process instance back out
       // of the database and resume execution by providing another
       // external signal.
       }
       finally
       {
       // Tear down the pojo persistence context.
       jbpmContext.close();
       }
       }
      
      
       public void runScheduler() throws Exception
       {
      // // Lookup the pojo persistence context-builder that is configured above
      // JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
      // try
      // {
       SchedulerThread schedulerThread = new SchedulerThread();
       schedulerThread.start();
      // }
      // finally
      // {
      // // Tear down the pojo persistence context.
      // jbpmContext.close();
      // }
       }
      }
      


      HERE ARE THE ACTION HANDLERS:
      package com.pb.mms.automation;
      
      import java.text.SimpleDateFormat;
      import java.util.Calendar;
      import java.util.Date;
      import java.util.GregorianCalendar;
      import java.util.Map;
      
      import org.apache.log4j.Logger;
      import org.jbpm.calendar.BusinessCalendar;
      import org.jbpm.calendar.Duration;
      import org.jbpm.context.exe.ContextInstance;
      import org.jbpm.graph.def.ActionHandler;
      import org.jbpm.graph.exe.ExecutionContext;
      import org.jbpm.graph.exe.ProcessInstance;
      import org.jbpm.graph.exe.Token;
      import org.jbpm.graph.node.DecisionHandler;
      import org.jbpm.scheduler.SchedulerService;
      import org.jbpm.scheduler.exe.Timer;
      import org.jbpm.svc.Services;
      
      public class ActionHandlers
      {
       static Timer timer = null;
       static Logger logger = Logger.getLogger( ActionHandlers.class );
      
       private static int counter = 3;
      
       /**
       * Used to calculate a date in the future, that takes place at the hours, minutes, seconds specified in
       * the indicated startTime. The startTime is formatted in 24 hour format, such as 15:23:21.
       *
       * @param startTime - String holding the hours, minutes, seconds, formatted as 'HH:MM:SS' in 24 hour format.
       * If null, then the current date is returned.
       */
       protected static Date getStartDate( String startTime )
       {
       // calculate the time when the timer should fire -- based on the specified startTime
       // if no startTime was specified, just use the current date
       if( startTime != null && startTime.length() > 0 )
       try
       {
       // load the HH:MM:SS AM/PM value from the process definition into a GregorianCalendar
       SimpleDateFormat sdf = new SimpleDateFormat( "H:m:s");
       GregorianCalendar startTimeCal = new GregorianCalendar();
       startTimeCal.setTime( sdf.parse( startTime ));
      
       // now copy the HH MM SS AN/PM fields into a today's date
       GregorianCalendar StartDateCal = new GregorianCalendar();
       StartDateCal.set( Calendar.HOUR_OF_DAY, startTimeCal.get( Calendar.HOUR_OF_DAY ));
       StartDateCal.set( Calendar.MINUTE, startTimeCal.get( Calendar.MINUTE ));
       StartDateCal.set( Calendar.SECOND, startTimeCal.get( Calendar.SECOND ));
      
       // and adjust into the future (24 hours later -- if the calculated start date has already passed
       while( StartDateCal.getTimeInMillis() < System.currentTimeMillis() )
       StartDateCal.add( Calendar.HOUR_OF_DAY, 24 );
      
       return StartDateCal.getTime();
       }
       catch( Exception e )
       {
       logger.error( "Could not calculate date for 1st firing of timer. startTime= " + startTime );
       logger.error( "Caught exception " + e, e );
       }
      
       return new Date();
       }
      
       public static class CreateCustomTimerAction implements ActionHandler
       {
       private static final long serialVersionUID = 1L;
      
       // These arguments get their values from the configuration in the processdefinition.
       // The values are injected directly by the engine.
       /** the name of the timer */
       String timerName;
       /** OPTIONAL - HH:MM:SS in 24 hour format when the timer should start every day */
       String startTime;
       /** OPTIONAL - when the timer should fire after the optional start time, or right now */
       String dueDate;
       /** OPTIONAL - the repeat interval for the timer */
       String repeat;
       /** The name of the transition to follow after the timer is fired */
       String transitionName;
       /** OPTIONAL -- name of the action to associate with the timer */
       String actionName;
      
       public void execute( ExecutionContext context ) throws Exception
       {
       logger.info( "@@@@@@@@@@@@@@@ processInstance=" + context.getProcessInstance().getId() + " entered wait state" );
      
       // if timer is already created, don't do anything
       if( timer != null )
       return;
      
       // context.getContextInstance().setVariable("message", message);
       logger.info( "@@@@@@@@@@@@@@@ Got the Create Custom Timer event... "
       + " configured as: "
       + " timer name=" + timerName
       + " start time=" + startTime
       + " duedate=" + dueDate
       + " repeat=" + repeat
       + " transitionName=" + transitionName
       + " action name=" + actionName );
      
       Token token = context.getToken();
      
       timer = new Timer( context.getToken() );
       timer.setName( timerName );
       Duration duration = new Duration( dueDate );
       BusinessCalendar businessCalendar = new BusinessCalendar();
       Date dueDate = businessCalendar.add( getStartDate( startTime ), duration );
       timer.setDueDate( dueDate );
       timer.setRepeat( repeat );
       timer.setTransitionName( transitionName );
       timer.setAction( context.getProcessDefinition().getAction( actionName ));
       timer.setGraphElement( context.getEventSource() );
       timer.setTaskInstance( context.getTaskInstance() );
      
       // Since this timer is not defined by the process, we need to use the SchedulerService to schedule the timer
       SchedulerService schedulerService = (SchedulerService) Services.getCurrentService( Services.SERVICENAME_SCHEDULER );
       schedulerService.createTimer( timer );
      
       logger.info( "@@@@@@@@@@@@@@@ timer=" + timer );
       }
       }
      
       public static class FireTimerAction implements ActionHandler
       {
       private static final long serialVersionUID = 1L;
      
       public void execute(ExecutionContext context) throws Exception
       {
       logger.info( "@@@@@@@@@@@@@@@ processInstance=" + context.getProcessInstance().getId()
       + " counter=" + counter
       + " currently at node=" + context.getToken().getNode().getFullyQualifiedName() );
       }
       }
      
       public static class RunMmsServiceAction implements ActionHandler
       {
       private static final long serialVersionUID = 1L;
      
       String serviceClass;
       Map serviceArguments;
      
       public void execute(ExecutionContext context) throws Exception
       {
       logger.info( "@@@@@@@@@@@@@@@ processInstance=" + context.getProcessInstance().getId()
       + " counter=" + counter
       + " currently at node=" + context.getToken().getNode().getFullyQualifiedName() );
       logger.info( "@@@@@@@@@@@@@@@ serviceClass=" + serviceClass
       + " and serviceArguments=" + serviceArguments );
      
      // MmsService mmsService = BSOFactory.getMmsService( serviceClass );
      //
      // if( serviceArguments == null )
      // mmsService.execute();
      // else
      // mmsService.execute( serviceArguments );
      //
      // mmsService.close();
       }
       }
      
      
       public static class EndOrRepeatDecision implements DecisionHandler
       {
       private static final long serialVersionUID = 1L;
      
       public String decide(ExecutionContext context)
       {
       logger.info( "@@@@@@@@@@@@@@@ processInstance=" + context.getProcessInstance().getId()
       + " counter="+ counter
       + " currently at node=" + context.getToken().getNode().getFullyQualifiedName() );
      
       if( --counter > 0 )
       {
       logger.info( "@@@@@@@@@@@@@@@ decision advancing to repeat-transition" );
       return "repeat-transition";
       }
       else
       {
       ProcessInstance processInstance = context.getToken().getProcessInstance();
       ContextInstance contextInstance = (ContextInstance) processInstance.getInstance(ContextInstance.class);
       contextInstance.setVariable( "request-end-process", new Integer(1));
      
       // Make sure the timer's don't get triggered again between now and when the process ends
      // logger.info( "@@@@@@@@@@@@@@@ cancelling timers for processInstance=" + processInstance.getId() );
      // SchedulerService schedulerService = (SchedulerService)Services.getCurrentService( Services.SERVICENAME_SCHEDULER );
      // schedulerService.cancelTimersByProcessInstance( context.getToken().getProcessInstance() );
      
       logger.info( "@@@@@@@@@@@@@@@ suspending timers for processInstance=" + processInstance.getId() );
       SchedulerService schedulerService = (SchedulerService)Services.getCurrentService( Services.SERVICENAME_SCHEDULER );
       schedulerService.suspendTimers( context.getToken() );
      
      
       // THE EXCEPTION IS THROWN AFTER RETURNING BELOW
       // WITH OR WITHOUT THE SCHEDULER CODE ABOVE
       logger.info( "@@@@@@@@@@@@@@@ decision advancing to end-transition" );
       return "end-transition";
       }
       }
       }
      }
      


      HERE IS THE STACK TRACE:

      20:30:10,546 [main] INFO ProcessManager : @@@@@@@@@@@@@@@@@@@@@@@ waiting for process to end......
      Hibernate: select tokenvaria0_.CONTEXTINSTANCE_ as CONTEXTI3_1_, tokenvaria0_.ID_ as ID1_1_, tokenvaria0_.TOKEN_ as TOKEN2_1_, tokenvaria0_.ID_ as ID1_24_0_, tokenvaria0_.TOKEN_ as TOKEN2_24_0_, tokenvaria0_.CONTEXTINSTANCE_ as CONTEXTI3_24_0_ from JBPM_TOKENVARIABLEMAP tokenvaria0_ where tokenvaria0_.CONTEXTINSTANCE_=?
      20:30:17,196 [JbpmScheduler] DEBUG VariableContainer : create variable 'request-end-process' in 'TokenVariableMap1c232a' with value '1'
      20:30:17,216 [JbpmScheduler] DEBUG Converters : adding converter 'D', 'org.jbpm.context.exe.converter.DoubleToStringConverter'
      20:30:17,226 [JbpmScheduler] DEBUG Converters : adding converter 'C', 'org.jbpm.context.exe.converter.CharacterToStringConverter'
      20:30:17,236 [JbpmScheduler] DEBUG Converters : adding converter 'B', 'org.jbpm.context.exe.converter.BooleanToStringConverter'
      20:30:17,276 [JbpmScheduler] DEBUG Converters : adding converter 'Y', 'org.jbpm.context.exe.converter.BytesToByteArrayConverter'
      20:30:17,276 [JbpmScheduler] DEBUG Converters : adding converter 'A', 'org.jbpm.context.exe.converter.DateToLongConverter'
      20:30:17,286 [JbpmScheduler] DEBUG Converters : adding converter 'R', 'org.jbpm.context.exe.converter.SerializableToByteArrayConverter'
      20:30:17,296 [JbpmScheduler] DEBUG Converters : adding converter 'I', 'org.jbpm.context.exe.converter.IntegerToLongConverter'
      20:30:17,296 [JbpmScheduler] DEBUG Converters : adding converter 'H', 'org.jbpm.context.exe.converter.ShortToLongConverter'
      20:30:17,306 [JbpmScheduler] DEBUG Converters : adding converter 'G', 'org.jbpm.context.exe.converter.FloatToDoubleConverter'
      20:30:17,306 [JbpmScheduler] DEBUG Converters : adding converter 'F', 'org.jbpm.context.exe.converter.FloatToStringConverter'
      20:30:17,316 [JbpmScheduler] DEBUG Converters : adding converter 'E', 'org.jbpm.context.exe.converter.ByteToLongConverter'
      20:30:17,336 [JbpmScheduler] INFO ActionHandlers$EndOrRepeatDecision : @@@@@@@@@@@@@@@ suspending timers for processInstance=2
      Hibernate: insert into JBPM_TOKENVARIABLEMAP (TOKEN_, CONTEXTINSTANCE_, ID_) values (?, ?, null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_VARIABLEINSTANCE (NAME_, CONVERTER_, TOKEN_, TOKENVARIABLEMAP_, PROCESSINSTANCE_, LONGVALUE_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, 'L', null)
      Hibernate: call identity()
      Hibernate: update JBPM_TIMER set ISSUSPENDED_=1 where TOKEN_=?
      20:30:17,356 [JbpmScheduler] INFO ActionHandlers$EndOrRepeatDecision : @@@@@@@@@@@@@@@ decision advancing to end-transition
      20:30:20,200 [JbpmScheduler] DEBUG Decision : selected transition name 'end-transition'
      20:30:20,200 [JbpmScheduler] DEBUG GraphElement : event 'node-leave' on 'Decision(Continue Or Shutdown)' for 'Token(/)'
      20:30:20,200 [JbpmScheduler] DEBUG GraphElement : event 'transition' on 'Transition(end-transition)' for 'Token(/)'
      Hibernate: select events0_.TRANSITION_ as TRANSITION7_1_, events0_.ID_ as ID1_1_, events0_.EVENTTYPE_ as EVENTTYPE2_1_, events0_.ID_ as ID1_7_0_, events0_.EVENTTYPE_ as EVENTTYPE2_7_0_, events0_.TYPE_ as TYPE3_7_0_, events0_.GRAPHELEMENT_ as GRAPHELE4_7_0_ from JBPM_EVENT events0_ where events0_.TRANSITION_=?
      Hibernate: select node0_.ID_ as ID1_5_0_, node0_.NAME_ as NAME3_5_0_, node0_.PROCESSDEFINITION_ as PROCESSD4_5_0_, node0_.ISASYNC_ as ISASYNC5_5_0_, node0_.ACTION_ as ACTION6_5_0_, node0_.SUPERSTATE_ as SUPERSTATE7_5_0_, node0_.SUBPROCESSDEFINITION_ as SUBPROCE8_5_0_, node0_.DECISIONEXPRESSION_ as DECISION9_5_0_, node0_.DECISIONDELEGATION as DECISIO10_5_0_, node0_.SIGNAL_ as SIGNAL11_5_0_, node0_.CREATETASKS_ as CREATET12_5_0_, node0_.ENDTASKS_ as ENDTASKS13_5_0_, node0_.CLASS_ as CLASS2_5_0_ from JBPM_NODE node0_ where node0_.ID_=?
      20:30:20,210 [JbpmScheduler] DEBUG GraphElement : event 'node-enter' on 'EndState(end1)' for 'Token(/)'
      Hibernate: select events0_.NODE_ as NODE6_1_, events0_.ID_ as ID1_1_, events0_.EVENTTYPE_ as EVENTTYPE2_1_, events0_.ID_ as ID1_7_0_, events0_.EVENTTYPE_ as EVENTTYPE2_7_0_, events0_.TYPE_ as TYPE3_7_0_, events0_.GRAPHELEMENT_ as GRAPHELE4_7_0_ from JBPM_EVENT events0_ where events0_.NODE_=?
      Hibernate: select children0_.PARENT_ as PARENT13_1_, children0_.ID_ as ID1_1_, children0_.NAME_ as NAME3_1_, children0_.ID_ as ID1_21_0_, children0_.VERSION_ as VERSION2_21_0_, children0_.NAME_ as NAME3_21_0_, children0_.START_ as START4_21_0_, children0_.END_ as END5_21_0_, children0_.NODEENTER_ as NODEENTER6_21_0_, children0_.NEXTLOGINDEX_ as NEXTLOGI7_21_0_, children0_.ISABLETOREACTIVATEPARENT_ as ISABLETO8_21_0_, children0_.ISTERMINATIONIMPLICIT_ as ISTERMIN9_21_0_, children0_.ISSUSPENDED_ as ISSUSPE10_21_0_, children0_.NODE_ as NODE11_21_0_, children0_.PROCESSINSTANCE_ as PROCESS12_21_0_, children0_.PARENT_ as PARENT13_21_0_, children0_.SUBPROCESSINSTANCE_ as SUBPROC14_21_0_ from JBPM_TOKEN children0_ where children0_.PARENT_=?
      Hibernate: select children0_.PARENT_ as PARENT13_1_, children0_.ID_ as ID1_1_, children0_.NAME_ as NAME3_1_, children0_.ID_ as ID1_21_0_, children0_.VERSION_ as VERSION2_21_0_, children0_.NAME_ as NAME3_21_0_, children0_.START_ as START4_21_0_, children0_.END_ as END5_21_0_, children0_.NODEENTER_ as NODEENTER6_21_0_, children0_.NEXTLOGINDEX_ as NEXTLOGI7_21_0_, children0_.ISABLETOREACTIVATEPARENT_ as ISABLETO8_21_0_, children0_.ISTERMINATIONIMPLICIT_ as ISTERMIN9_21_0_, children0_.ISSUSPENDED_ as ISSUSPE10_21_0_, children0_.NODE_ as NODE11_21_0_, children0_.PROCESSINSTANCE_ as PROCESS12_21_0_, children0_.PARENT_ as PARENT13_21_0_, children0_.SUBPROCESSINSTANCE_ as SUBPROC14_21_0_ from JBPM_TOKEN children0_ where children0_.PARENT_=?
      Hibernate: select children0_.PARENT_ as PARENT13_1_, children0_.ID_ as ID1_1_, children0_.NAME_ as NAME3_1_, children0_.ID_ as ID1_21_0_, children0_.VERSION_ as VERSION2_21_0_, children0_.NAME_ as NAME3_21_0_, children0_.START_ as START4_21_0_, children0_.END_ as END5_21_0_, children0_.NODEENTER_ as NODEENTER6_21_0_, children0_.NEXTLOGINDEX_ as NEXTLOGI7_21_0_, children0_.ISABLETOREACTIVATEPARENT_ as ISABLETO8_21_0_, children0_.ISTERMINATIONIMPLICIT_ as ISTERMIN9_21_0_, children0_.ISSUSPENDED_ as ISSUSPE10_21_0_, children0_.NODE_ as NODE11_21_0_, children0_.PROCESSINSTANCE_ as PROCESS12_21_0_, children0_.PARENT_ as PARENT13_21_0_, children0_.SUBPROCESSINSTANCE_ as SUBPROC14_21_0_ from JBPM_TOKEN children0_ where children0_.PARENT_=?
      Hibernate: select children0_.PARENT_ as PARENT13_1_, children0_.ID_ as ID1_1_, children0_.NAME_ as NAME3_1_, children0_.ID_ as ID1_21_0_, children0_.VERSION_ as VERSION2_21_0_, children0_.NAME_ as NAME3_21_0_, children0_.START_ as START4_21_0_, children0_.END_ as END5_21_0_, children0_.NODEENTER_ as NODEENTER6_21_0_, children0_.NEXTLOGINDEX_ as NEXTLOGI7_21_0_, children0_.ISABLETOREACTIVATEPARENT_ as ISABLETO8_21_0_, children0_.ISTERMINATIONIMPLICIT_ as ISTERMIN9_21_0_, children0_.ISSUSPENDED_ as ISSUSPE10_21_0_, children0_.NODE_ as NODE11_21_0_, children0_.PROCESSINSTANCE_ as PROCESS12_21_0_, children0_.PARENT_ as PARENT13_21_0_, children0_.SUBPROCESSINSTANCE_ as SUBPROC14_21_0_ from JBPM_TOKEN children0_ where children0_.PARENT_=?
      20:30:20,220 [JbpmScheduler] DEBUG GraphElement : event 'process-end' on 'ProcessDefinition(Load Confirm Data Process)' for 'Token(/)'
      Hibernate: delete from JBPM_TIMER where PROCESSINSTANCE_=?
      20:30:20,240 [JbpmScheduler] DEBUG GraphElement : event 'after-signal' on 'State(Wait For Start Time)' for 'Token(/)'
      20:30:20,240 [JbpmScheduler] DEBUG Services : executing default save operations
      20:30:20,250 [JbpmScheduler] DEBUG HibernateSaveOperation : saving process instance
      20:30:20,250 [JbpmScheduler] DEBUG SaveLogsOperation : flushing logs to logging service.
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, TRANSITION_, CLASS_, ID_) values (?, ?, ?, ?, ?, 'S', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, EXCEPTION_, ACTION_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, 'A', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, NODE_, ENTER_, LEAVE_, DURATION_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, ?, 'N', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, TRANSITION_, SOURCENODE_, DESTINATIONNODE_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, 'T', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, CHILD_, CLASS_, ID_) values (?, ?, ?, ?, ?, 'O', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, CHILD_, CLASS_, ID_) values (?, ?, ?, ?, ?, 'O', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, TRANSITION_, SOURCENODE_, DESTINATIONNODE_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, 'T', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, EXCEPTION_, ACTION_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, 'A', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, NODE_, ENTER_, LEAVE_, DURATION_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, ?, 'N', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, TRANSITION_, SOURCENODE_, DESTINATIONNODE_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, 'T', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, TRANSITION_, SOURCENODE_, DESTINATIONNODE_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, 'T', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, EXCEPTION_, ACTION_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, 'A', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, NODE_, ENTER_, LEAVE_, DURATION_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, ?, 'N', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, TRANSITION_, SOURCENODE_, DESTINATIONNODE_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, 'T', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, NODE_, ENTER_, LEAVE_, DURATION_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, ?, 'N', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, TRANSITION_, SOURCENODE_, DESTINATIONNODE_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, 'T', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, EXCEPTION_, ACTION_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, 'A', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, NODE_, Eorg.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session
       at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:171)
       at org.jbpm.svc.Services.close(Services.java:211)
       at org.jbpm.JbpmContext.close(JbpmContext.java:141)
       at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread.java:161)
       at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:70)
       Caused by: org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
       at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:93)NTER_, LEAVE_, DURATION_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, ?, 'N', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, TRANSITION_, SOURCENODE_, DESTINATIONNODE_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, 'T', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, EXCEPTION_, ACTION_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, 'A', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, NODE_, ENTER_, LEAVE_, DURATION_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, ?, 'N', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, TRANSITION_, SOURCENODE_, DESTINATIONNODE_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, 'T', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, EXCEPTION_, ACTION_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, 'A', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, NODE_, ENTER_, LEAVE_, DURATION_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, ?, 'N', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, TRANSITION_, SOURCENODE_, DESTINATIONNODE_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, 'T', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, VARIABLEINSTANCE_, CLASS_, ID_) values (?, ?, ?, ?, ?, 'R', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, VARIABLEINSTANCE_, OLDLONGVALUE_, NEWLONGVALUE_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, 'G', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, NODE_, ENTER_, LEAVE_, DURATION_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, ?, 'N', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, TRANSITION_, SOURCENODE_, DESTINATIONNODE_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, 'T', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, CHILD_, CLASS_, ID_) values (?, ?, ?, ?, ?, 'Y', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, CHILD_, CLASS_, ID_) values (?, ?, ?, ?, ?, 'Y', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, CHILD_, CLASS_, ID_) values (?, ?, ?, ?, ?, 'Y', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, CHILD_, CLASS_, ID_) values (?, ?, ?, ?, ?, 'Y', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, CHILD_, CLASS_, ID_) values (?, ?, ?, ?, ?, 'Y', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, CHILD_, CLASS_, ID_) values (?, ?, ?, ?, ?, 'Y', null)
      Hibernate: call identity()
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, CLASS_, ID_) values (?, ?, ?, ?, 'X', null)
      Hibernate: call identity()
      20:30:20,290 [JbpmScheduler] DEBUG CascadeSaveOperation : cascading save of 'org.jbpm.graph.exe.ProcessInstance@1ffdf86'
      20:30:20,290 [JbpmScheduler] DEBUG SchedulerThread : saving updated timer for repetition 'timer(start-confirm-automated-tasks,20:30:48,979)' in '28689' millis
      20:30:20,290 [JbpmScheduler] DEBUG JbpmContext : closing JbpmContext
      20:30:20,290 [JbpmScheduler] DEBUG Services : closing service 'persistence': org.jbpm.persistence.db.DbPersistenceService@13552ed
      20:30:20,300 [JbpmScheduler] DEBUG DbPersistenceService : committing hibernate transaction
      Hibernate: update JBPM_TIMER set NAME_=?, DUEDATE_=?, REPEAT_=?, TRANSITIONNAME_=?, EXCEPTION_=?, ISSUSPENDED_=?, ACTION_=?, TOKEN_=?, PROCESSINSTANCE_=?, TASKINSTANCE_=?, GRAPHELEMENTTYPE_=?, GRAPHELEMENT_=? where ID_=?
      20:30:20,310 [JbpmScheduler] ERROR BatchingBatcher : Exception executing batch:
       org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
       at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:93)
       at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:79)
       at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
       at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
       at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:91)
       at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:86)
       at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2166)
       at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
       at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
       at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:84)
       at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
       at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
       at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
       at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:353)
       at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
       at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:161)
       at org.jbpm.svc.Services.close(Services.java:211)
       at org.jbpm.JbpmContext.close(JbpmContext.java:141)
       at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread.java:161)
       at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:70)
       20:30:20,330 [JbpmScheduler] ERROR AbstractFlushingEventListener : Could not synchronize database state with session
       org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
       at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:93)
       at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:79)
       at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
       at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
       at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:91)
       at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:86)
       at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2166)
       at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
       at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
       at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:84)
       at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
       at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
       at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
       at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:353)
       at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
       at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:161)
       at org.jbpm.svc.Services.close(Services.java:211)
       at org.jbpm.JbpmContext.close(JbpmContext.java:141)
       at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread.java:161)
       at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:70)
      
       at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:79)
       at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
       at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
       at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:91)
       at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:86)
       at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2166)
       at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
       at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
       at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:84)
       at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
       at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
       at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
       at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:353)
       at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
       at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:161)
       ... 4 more
       20:30:20,380 [JbpmScheduler] ERROR Services : problem closing service 'persistence'
       org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session
       at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:171)
       at org.jbpm.svc.Services.close(Services.java:211)
       at org.jbpm.JbpmContext.close(JbpmContext.java:141)
       at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread.java:161)
       at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:70)
       Caused by: org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
       at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:93)
       at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:79)
       at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
       at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
       at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:91)
       at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:86)
       at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2166)
       at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
       at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
       at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:84)
       at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
       at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
       at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
       at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:353)
       at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
       at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:161)
       ... 4 more
       20:30:20,390 [JbpmScheduler] DEBUG Services : closing service 'scheduler': org.jbpm.scheduler.db.DbSchedulerService@18aea9e
       20:30:20,390 [JbpmScheduler] DEBUG Services : closing service 'logging': org.jbpm.logging.db.DbLoggingService@182f3da
       20:30:20,390 [JbpmScheduler] INFO SchedulerThread : runtime exception while executing timers
       org.jbpm.JbpmException: problem closing services {persistence=org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session}
       at org.jbpm.svc.Services.close(Services.java:223)
       at org.jbpm.JbpmContext.close(JbpmContext.java:141)
       at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread.java:161)
       at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:70)
       Caused by: org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session
       at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:171)
       at org.jbpm.svc.Services.close(Services.java:211)
       ... 3 more
       Caused by: org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
       at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:93)
       at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:79)
       at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
       at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
       at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:91)
       at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:86)
       at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2166)
       at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
       at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
       at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:84)
       at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
       at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
       at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
       at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:353)
       at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
       at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:161)
       ... 4 more
      


        • 1. Re: Failure when ending process
          jrojas_pb Newbie

          I removed the exception as follows:

          I redesigned the process definition so that the end-transition takes place from the wait state. This is the new shutdown procedure:
          1. The decision node suspends the timer
          2. The decision node sets the context variable
          3. The decision node always moves back to the wait state

          4. The ProcessManager detects the variable has been set
          5. The ProcessManager asserts the process is in the Wait State
          6. The ProcessManager signals("end-transition")

          7. The process ends (without any exceptions).

          I don't know why the original version threw an exception. I am just glad this is working.

          Image of new process definition:
          http://tinypic.com/view/?pic=4dg12k3

          [img]http://i10.tinypic.com/4dg12k3.jpg[/img]

          HERE IS THE UPDATED CODE IN endProcess(...):

           // At this point the process should be in the wait state
           assertEquals( "Instance is wait state", processInstance.getRootToken().getNode().getName(), "Wait For Start Time");
          
           // Signal the process to end
           processInstance.signal( "end-transition" );
          
           assertEquals( "Instance is end state", processInstance.getRootToken().getNode().getName(), "end");
          


          • 2. Re: Failure when ending process
            Jim Knopf Newbie

            Thanks for ur answer.
            And sorry for the late answer from me :(.
            I did it now like u said and it is working.