cancel
Showing results for 
Search instead for 
Did you mean: 

Really simple timer start event throwing exception

ct1
Champ in-the-making
Champ in-the-making
Sirs:

I am working with Activiti 5.9 on a Windows 7 OS.

My use case is to have a process start at 8:00 a.m. each day.  I wrote a very simple process with a Timer Start Event coded to start the process one time at the specified time (I am not trying to have the process start on a recurring basis yet, just start once). 

I deployed the process using Activiti Explorer.  The tomcat log shows the deployment. 

When the time arrives, I see the exception shown below. 

The log seems to show a second deployment of all (both) of my processes after the exception. 

The process does seem to start because I see output from the script task that follows the Timer Start Event. 

My questions are:

1.  Is this behavior I should expect?  By that, I mean, should I expect an exception to be thrown when I use a timer start event to start a process?

2.  Does a second deployment of all my processes really happen (maybe I am just misreading the log)?  What if I have two or three hundred processes defined?

Thank you.


The bpmn20.xml file:


<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:activiti="http://activiti.org/bpmn"
   xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
   xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
   xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI"
   typeLanguage="http://www.w3.org/2001/XMLSchema"
   expressionLanguage="http://www.w3.org/1999/XPath"
   targetNamespace="http://www.activiti.org/test">
  <process id="timeStartProc01" name="Timer Start Proc 01">
    <startEvent id="timerProc01Start" name="Timer Proc01 Start ">
      <timerEventDefinition>
        <timeDate>2012-05-07T15:15:00</timeDate>
      </timerEventDefinition>
    </startEvent>
    <scriptTask id="scripttask1" name="Script Task" scriptFormat="groovy">
      <script><![CDATA[Date timerStarted = new Date();
String timerStartedStr = timerStarted.format('yyyy/MM/dd HH:mm:ss SSS');
print "Timer-Start-Proc 01 logged at $timerStartedStr \n";]]></script>
    </scriptTask>
    <endEvent id="timerStartProc01End" name="tTmer Start Proc01 End"></endEvent>
    <sequenceFlow id="flow1" name="" sourceRef="timerProc01Start" targetRef="scripttask1"></sequenceFlow>
    <sequenceFlow id="flow2" name="" sourceRef="scripttask1" targetRef="timerStartProc01End"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_timeStartProc01">
    <bpmndi:BPMNPlane bpmnElement="timeStartProc01" id="BPMNPlane_timeStartProc01">
      <bpmndi:BPMNShape bpmnElement="timerProc01Start" id="BPMNShape_timerProc01Start">
        <omgdc:Bounds height="35" width="35" x="110" y="230"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="scripttask1" id="BPMNShape_scripttask1">
        <omgdc:Bounds height="55" width="105" x="220" y="220"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="timerStartProc01End" id="BPMNShape_timerStartProc01End">
        <omgdc:Bounds height="35" width="35" x="390" y="230"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="145" y="247"></omgdi:waypoint>
        <omgdi:waypoint x="220" y="247"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="325" y="247"></omgdi:waypoint>
        <omgdi:waypoint x="390" y="247"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>


The exception:

    May 7, 2012 3:12:39 PM org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy                         <—— Initial deployment
    INFO: Processing resource WF-Proc-1.bpmn20.xml
    May 7, 2012 3:12:39 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
    INFO: XMLSchema currently not supported as typeLanguage
    May 7, 2012 3:12:39 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
    INFO: XPath currently not supported as expressionLanguage
    May 7, 2012 3:12:39 PM org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
    INFO: Processing resource Timer-Start-Proc01.bpmn20.xml
    May 7, 2012 3:12:39 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
    INFO: XMLSchema currently not supported as typeLanguage
    May 7, 2012 3:12:39 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
    INFO: XPath currently not supported as expressionLanguage
    May 7, 2012 3:15:00 PM org.activiti.engine.impl.interceptor.CommandContext close                             <—– Specified start time
    SEVERE: Error while closing command context
    org.activiti.engine.ActivitiOptimisticLockingException: TimerEntity[361] was updated by another tran      <—– Exception
    saction concurrently
            at org.activiti.engine.impl.db.DbSqlSession.flushUpdates(DbSqlSession.java:452)
            at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:348)
            at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:149
    )
            at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:105)
            at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInte
    rceptor.java:49)
            at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInter
    ceptor.java:42)
            at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.j
    ava:130)
            at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.jav
    a:40)
            at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
            at org.activiti.engine.impl.jobexecutor.AcquireJobsRunnable.run(AcquireJobsRunnable.java:57)

            at java.lang.Thread.run(Thread.java:662)
    May 7, 2012 3:15:00 PM org.activiti.engine.impl.jobexecutor.AcquireJobsRunnable run
    SEVERE: exception during job acquisition: TimerEntity[361] was updated by another transaction concur
    rently
    org.activiti.engine.ActivitiOptimisticLockingException: TimerEntity[361] was updated by another tran
    saction concurrently
            at org.activiti.engine.impl.db.DbSqlSession.flushUpdates(DbSqlSession.java:452)
            at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:348)
            at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:149
    )
            at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:105)
            at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInte
    rceptor.java:49)
            at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInter
    ceptor.java:42)
            at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.j
    ava:130)
            at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.jav
    a:40)
            at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
            at org.activiti.engine.impl.jobexecutor.AcquireJobsRunnable.run(AcquireJobsRunnable.java:57)

            at java.lang.Thread.run(Thread.java:662)
    May 7, 2012 3:15:00 PM org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy                        <—– Second deployment ???
    INFO: Processing resource Timer-Start-Proc01.timeStartProc01.png
    May 7, 2012 3:15:00 PM org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
    INFO: Processing resource WF-Proc-1.bpmn20.xml
    May 7, 2012 3:15:00 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
    INFO: XMLSchema currently not supported as typeLanguage
    May 7, 2012 3:15:00 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
    INFO: XPath currently not supported as expressionLanguage
    May 7, 2012 3:15:00 PM org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
    INFO: Processing resource WF-Proc-1.WF-Proc-1.png
    May 7, 2012 3:15:00 PM org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
    INFO: Processing resource Timer-Start-Proc01.bpmn20.xml
    May 7, 2012 3:15:00 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
    INFO: XMLSchema currently not supported as typeLanguage
    May 7, 2012 3:15:00 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
    INFO: XPath currently not supported as expressionLanguage
    Timer-Start-Proc 01 logged at 2012/05/07 15:15:00 120                                                                <— Output of Script task
4 REPLIES 4

trademak
Star Contributor
Star Contributor
Hi,

I just tested your example process in a simple unit test and that's working fine.
Also in the Activiti Explorer it's working fine.
Are you running multiple Activiti Engines on one database?

Best regards,

ct1
Champ in-the-making
Champ in-the-making
Thank you for testing this.

When I ran this test initially, only one Process Engine was running, the one used by Activiti Explorer.

I just reran the process in Explorer to confirm the behavior noted.  It was the same as before.

Was your unit test written to catch the ActivitiOptimisticLockingException (and any other throwable)?

In your Expolorer test, did you see evidence in your log or console of a second deployment of all your processes when the Timer Start Event was supposed to start?

Thank you.

trademak
Star Contributor
Star Contributor
Hi,

No my unit test didn't catch any exceptions.
In the Explorer I saw some log statements of processes retrieved multiple times, but that doesn't cause multiple deployments.
Do you see that processes are deployed multiple times in the Manage section?

Best regards,

ct1
Champ in-the-making
Champ in-the-making
Thank you for the information.

You were right, I did not notice the revision number of the process definitions getting higher, so it must be that the Deployer is simply parsing all the bpmn.20 files rather that deploying them.  That is a relief; but then, with the possiblilty of hundreds of processes being defined in the database, the parsing may be repeated each time a Process Engine is created by the Java API calls.  Would there be some way to direct the Deployer to parse only when the bpmn.20 file is loaded to run?  Or to parse only the bpmn.20 files that have not been parsed?

There is still the question, should I expect an exception to be thrown when I use a timer start event to start a process?  It seems reasonable to think that a process may be scheduled to start at a certain time and a used might be signed on to Explorer at that time completing a User Task in some other process.

Thank you for your continued help.