cancel
Showing results for 
Search instead for 
Did you mean: 

ActivitiException when trying to run workflow

vram
Champ in-the-making
Champ in-the-making
Hi,

I am trying to run a multi instance workflow for my service task which has a delay in it.( I am using Thread.sleep in my service task for 180000 ms) .During this, the jobs are executed fine but at the completion of the last iteration, I see an exception as :


org.activiti.engine.ActivitiException: No job found with id '4633'
   at org.activiti.engine.impl.cmd.ExecuteJobsCmd.execute(ExecuteJobsCmd.java:57)
   at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:36)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
   at java.lang.Thread.run(Thread.java:722)

After this all my previous iteration service tasks are aborted ..My BPMN:


<?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" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="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="SeqTest" name="seqTest">
    <documentation>Place documentation for the 'seqTest' process here.</documentation>
    <startEvent id="startevent1" name="Start"></startEvent>
    <serviceTask id="servicetask1" name="Service Task" activiti:class="com.mikewidgets.helloWorld.SayHelloTask">
      <multiInstanceLoopCharacteristics isSequential="true">
        <loopCardinality>10</loopCardinality>
      </multiInstanceLoopCharacteristics>
    </serviceTask>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
    <sequenceFlow id="flow2" name="" sourceRef="servicetask1" targetRef="endevent1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_SeqTest">
    <bpmndi:BPMNPlane bpmnElement="SeqTest" id="BPMNPlane_SeqTest">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35" width="35" x="190" y="120"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask1" id="BPMNShape_servicetask1">
        <omgdc:Bounds height="55" width="105" x="420" y="180"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35" width="35" x="470" y="300"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="207" y="155"></omgdi:waypoint>
        <omgdi:waypoint x="472" y="180"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="472" y="235"></omgdi:waypoint>
        <omgdi:waypoint x="487" y="300"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>


It would be great if someone could  help resolve this
10 REPLIES 10

frederikherema1
Star Contributor
Star Contributor
Not sure if this is the problem, but there is a timeout on jobs, when they take too long to execute (they are unlocked an retried after a timeout), see http://forums.activiti.org/en/viewtopic.php?f=6&t=4139&p=16098&hilit=job+lock#p16098

On top of that, to prevent job-executor not to block all of it's threads too long, a max-lock time is set (default is 5 minutes: int lockTimeInMillis = 5 * 60 * 1000Smiley Wink. If expired, job executor presumes something went wrong and unlocks the job, effectively marking it to be executed again.
The lock-time is a setter on the JobExecutor and can be altered in configuration or even from code, so this can be raised.

I don't see any timer-declarations in your process, where are the jobs coming from?

vram
Champ in-the-making
Champ in-the-making
Hi frederikheremans,

Thanks for the valuable reply. Can you let me know how this time could be configured ? I would want to increase the time limit and see if this exception happens  even then ..

This exception is not happening in case of normal tasks( service tasks with Thread.sleep() in it) . It is happening only when the tasks are in a loop ( Even then , for small loop iteration count like 2 or 3 the exception does not occur. It happens only for large iteration values like 9 or 10 )

frederikherema1
Star Contributor
Star Contributor
Please read the post I referred to, it contains a code-snippet showing the configuration (http://forums.activiti.org/en/viewtopic.php?f=6&t=4139&p=16098&hilit=job+lock#p16098)

vram
Champ in-the-making
Champ in-the-making
Thanks frederikheremans I have now configured the activiti.cfg.xml with the parameter for lockTimeInMillis. But my run time is always picking up the default value of 5 * 60 * 1000 specified in the code level. Am I missing anything here ?

vram
Champ in-the-making
Champ in-the-making
Thanks frederikheremans . I am now successfully able to change configurations.

vram
Champ in-the-making
Champ in-the-making
Hi,


I am able to configure the lockTime to a higher value and could see the process run . But at the end, after the last iteration had been complete the following exception occurs and all the previous iterations are aborted.

### Error updating database.  Cause: org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "PRIMARY_KEY_80 ON PUBLIC.ACT_HI_DETAIL(ID_)"; SQL statement:
insert into ACT_HI_DETAIL (ID_, TYPE_, PROC_INST_ID_, EXECUTION_ID_, ACT_INST_ID_, TASK_ID_, NAME_, REV_, VAR_TYPE_, TIME_, BYTEARRAY_ID_, DOUBLE_, LONG_ , TEXT_, TEXT2_)
    values (
      ?,
      'VariableUpdate',
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?
    ) [23001-132]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:316)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.index.BaseIndex.getDuplicateKeyException(BaseIndex.java:157)
at org.h2.index.PageBtree.find(PageBtree.java:115)
at org.h2.index.PageBtreeLeaf.addRow(PageBtreeLeaf.java:137)
at org.h2.index.PageBtreeLeaf.addRowTry(PageBtreeLeaf.java:92)
at org.h2.index.PageBtreeNode.addRowTry(PageBtreeNode.java:200)
at org.h2.index.PageBtreeIndex.addRow(PageBtreeIndex.java:88)
at org.h2.index.PageBtreeIndex.add(PageBtreeIndex.java:79)
at org.h2.table.RegularTable.addRow(RegularTable.java:112)
at org.h2.command.dml.Insert.insertRows(Insert.java:120)
at org.h2.command.dml.Insert.update(Insert.java:82)
at org.h2.command.CommandContainer.update(CommandContainer.java:70)
at org.h2.command.Command.executeUpdate(Command.java:198)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:298)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:135)
at java.lang.Thread.run(Thread.java:722)

### The error may involve org.activiti.engine.impl.persistence.entity.HistoricDetailEntity.insertHistoricVariableUpdate-Inline
### The error occurred while setting parameters
### Cause: org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "PRIMARY_KEY_80 ON PUBLIC.ACT_HI_DETAIL(ID_)"; SQL statement:
insert into ACT_HI_DETAIL (ID_, TYPE_, PROC_INST_ID_, EXECUTION_ID_, ACT_INST_ID_, TASK_ID_, NAME_, REV_, VAR_TYPE_, TIME_, BYTEARRAY_ID_, DOUBLE_, LONG_ , TEXT_, TEXT2_)
    values (
      ?,
      'VariableUpdate',
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?
    ) [23001-132]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:316)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.index.BaseIndex.getDuplicateKeyException(BaseIndex.java:157)
at org.h2.index.PageBtree.find(PageBtree.java:115)
at org.h2.index.PageBtreeLeaf.addRow(PageBtreeLeaf.java:137)
at org.h2.index.PageBtreeLeaf.addRowTry(PageBtreeLeaf.java:92)
at org.h2.index.PageBtreeNode.addRowTry(PageBtreeNode.java:200)
at org.h2.index.PageBtreeIndex.addRow(PageBtreeIndex.java:88)
at org.h2.index.PageBtreeIndex.add(PageBtreeIndex.java:79)
at org.h2.table.RegularTable.addRow(RegularTable.java:112)
at org.h2.command.dml.Insert.insertRows(Insert.java:120)
at org.h2.command.dml.Insert.update(Insert.java:82)
at org.h2.command.CommandContainer.update(CommandContainer.java:70)
at org.h2.command.Command.executeUpdate(Command.java:198)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:298)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:135)
at java.lang.Thread.run(Thread.java:722)


This exception does not occur , if the loop iteration value is small( like 3 or 4). It occurs only when the loop iteration value is set 10 or higher. Could you please help resolve this?

frederikherema1
Star Contributor
Star Contributor
That's really strange… Looks like something goes wrong with the ID-generator, it should generate id's for synchronized in the engine.

What is the transaction-strategy used? Do you hook in to spring-transactions or something?

vram
Champ in-the-making
Champ in-the-making
Hi  frederikheremans,

I invoke activiti from my workflows and not through spring. Are you referring to it?

vram
Champ in-the-making
Champ in-the-making
Thanks frederikheremans. I created my activiti database once and now the exception is all gone Smiley Happy


Thanks for your support.

Can you let me know as to how I can  set the lockTimeInMillis parameter through program instead of the activiti.cfg.xml