AnsweredAssumed Answered

Error on loop with asynchronous activities

Question asked by mmaker1234 on May 13, 2013
Latest reply on May 16, 2013 by mmaker1234
Hello Activiti developers,

I wanted to better understand what is the actual behavior of the "local" and "global" process variables and started with an example, which revealed many problems.

Please find attached a simplified example to demonstrate two of these problems: a process definition with three script (JavaScript) activities (
initVars
,
inc
, and
printVars
) and an XOR gateway.

The problem with the attached process definition is that any process instance execution fails with[java]May 13, 2013 3:00:21 PM org.activiti.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
org.activiti.engine.ActivitiException: Query return 2 results instead of max 1
    at org.activiti.engine.impl.AbstractQuery.executeSingleResult(AbstractQuery.java:162)
    at org.activiti.engine.impl.AbstractQuery.execute(AbstractQuery.java:141)
    at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
    at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:61)
    …[/java]

The process definition is attached as TestLocalVariablesSimple.bpmn_.txt (of course you should rename it to TestLocalVariablesSimple.bpmn in order to review it) and a process instance execution log is attached as TestLocalVariablesSimple.log_.txt

While reading the execution log you will see
org.activiti.engine.impl.cmd.NoJobRetriesCmd
- this is my modification of the Activiti's DecrementJobRetriesCmd - I just do not want the jobs to retry. I can provide its code if you need it.

If I remove the Asynchronous flag from the activities included in the loop (
inc
and
printVars
) the process instance runs fine for small number of cycle repetitions.

The other problem is that each run fails with the following error when I increase the limit of the cycle to 100 : [java]
INFO: start Activity definitionId=inc, processId=77915, executionId=77915, name='inc', with properties: {default=null, name=inc, documentation=null, type=scriptTask}, persistent state: {isActive=true, activityId=inc, parentId=null, isScope=true, cachedEntityState=4, businessKey=null, suspensionState=1, isEventScope=false, superExecution=null, processDefinitionId=TestLocalVariablesSimple:5:77914, isConcurrent=false}, ProcessInstance id=77915, Execution id=77915, ProcessDefinition(id)='TestLocalVariablesSimple:5:77914', vegas_version: 'null', Scope
Exception in thread "pool-1-thread-4" java.lang.StackOverflowError
    ….
[/java]It seems that the execution of the consecutive activities runs in the context of the JavaScript expression, which does not seems correct.

Please find the details in the attached process definition TestLocalVariablesSimpleSynchronous .bpmn_.txt and the corresponding execution log TestLocalVariablesSimpleSynchronous.log_.txt

Please help me to sort out these two problems.

Best Regards,
Monique

Outcomes