AnsweredAssumed Answered

Process started in Activiti Explorer results in integrity constraint violation, but starting programmatically is OK

Question asked by slehman on May 24, 2013
Latest reply on May 28, 2013 by jbarrez
I'm making the case for Activiti at my company and have been getting my feet wet by trying to figure out how to work with some long-running asynchronous processes.   The receive task looks like the way to go, but I've already run into a problem.

My process is simply  start -> receive -> end.   When I start a process programmatically, I can signal the execution, and things work as expected.  But when I start the process using Activiti Explorer (running as a standalone .war), after signaling the execution, I see an exception:

SEVERE: Error while closing command context
### Error updating database.  Cause: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "ACT_FK_IDL_PROCINST: PUBLIC.ACT_RU_IDENTITYLINK FOREIGN KEY(PROC_INST_ID_) REFERENCES PUBLIC.ACT_RU_EXECUTION(ID_) ('3070')"; SQL statement:
delete from ACT_RU_EXECUTION where ID_ = ? [23503-171]
   at org.h2.message.DbException.getJdbcSQLException(
   at org.h2.message.DbException.get(
   at org.h2.message.DbException.get(
   at org.h2.constraint.ConstraintReferential.checkRow(
   at org.h2.constraint.ConstraintReferential.checkRowRefTable(
   at org.h2.constraint.ConstraintReferential.checkRow(
   at org.h2.table.Table.fireConstraints(
   at org.h2.table.Table.fireAfterRow(
   at org.h2.command.dml.Delete.update(
   at org.h2.command.CommandContainer.update(
   at org.h2.command.Command.executeUpdate(
   at org.h2.server.TcpServerThread.process(
   at Source)

I can see the entries in ACT_RU_IDENTITYLINK that are created only when Explorer is used to start the process, but I am at a loss for what I need to do to make this work.

My process definition is:

<?xml version="1.0" encoding="UTF-8" ?>
<definitions id="definitions"
  <process id="myVacationRequest" name="My Vacation request">
    <startEvent id="request" >
    <sequenceFlow id="flow1" sourceRef="request" targetRef="wait2" />
    <receiveTask id="wait2" name="wait"/>
    <sequenceFlow id="flow2a" sourceRef="wait2" targetRef="theEnd1" />
    <endEvent id="theEnd1" />

The code I'm using is:

      ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
      if (processEngine == null) {
         log.error("Could not start Activiti Engine");
      else {
         RepositoryService repositoryService = processEngine.getRepositoryService();
              "Number of process definitions: " + repositoryService.createProcessDefinitionQuery().count());           
         // This process will complete as expected
          String procId = processEngine.getRuntimeService().startProcessInstanceByKey("myVacationRequest").getId();

          // Start a process in Activiti Explorer - it will result in an exception at the end of the process
          try {
         } catch (InterruptedException e) {
            // TODO Auto-generated catch block

          // Lookup executions in our wait activity, and signal them to advance
          RuntimeService rs = processEngine.getRuntimeService();
         List<Execution> executions = rs.createExecutionQuery().processDefinitionKey("myVacationRequest").activityId("wait2").list();
         for (Execution execution : executions) {
  "Found execution " + execution.getId());
            try {
            } catch (RuntimeException e) {

Is there some other key step to using the Receive task that I'm missing?