AnsweredAssumed Answered

Set a variable after ActivitiExecution.take results in foreign key constraint violation error

Question asked by andrealuciano71 on Aug 18, 2015
Latest reply on Aug 19, 2015 by andrealuciano71

    I've encountered the error described below  (occured with Activiti BPM 5.18) while playing with ActivityBehavior .

    I'm just wondering whether it is an issue or I've just misused a ActivityExecution reference.

    I've made a simple unit test consisting of a start event, a service task and a none end event.

   The service task just calls the Java test.BpmTaskUnitTest1 class below.

package test;

import org.activiti.engine.impl.pvm.PvmActivity;
import org.activiti.engine.impl.pvm.delegate.ActivityBehavior;
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;

public class BpmTaskUnitTest1  implements ActivityBehavior {

    * Set serial version
   private static final long serialVersionUID = 1L;

   public void execute(ActivityExecution execution) throws Exception {
      PvmActivity activity = execution.getActivity();
      System.out.println("[DEBUG] —-> call ActivityExecution.take");

      System.out.println("[DEBUG] —-> set variable");
      execution.setVariable("variable", "myValue");

   When stated the process raises the exception of "java.sql.SQLIntegrityConstraintViolationException: ORA-02292: integrity constraint (OGW_BPM_3.ACT_FK_VAR_EXE) violated - child record found.

   Setting the debug level for both iBatis and Activiti log, I observed that DbSqlSession class tried to insert a "VariableInstanceEntity" while there wasn't a corresponding  parent table record any longer:

   … persistence.entity.ExecutionEntity - destroying ProcessInstance[712534]
   … impl.db.DbSqlSession - flush summary: 10 insert, 0 update, 0 delete.
   … impl.db.DbSqlSession -   insert VariableInstanceEntity[id=712541, name=variable, …
   impl.interceptor.CommandContext - Error while closing command context org.apache.ibatis.exceptions.PersistenceException:

   ### Error updating database.  Cause: java.sql.SQLIntegrityConstraintViolationException:
             ORA-02291: integrity constraint (OGW_BPM.ACT_FK_VAR_PROCINST) violated - parent key not found