cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti 6: Cannot Cancel Process

chrisx_212
Champ in-the-making
Champ in-the-making
Everytime I try to cancel a process in Activiti 6, I get this message:

### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`activiti6`.`act_ru_execution`, CONSTRAINT `ACT_FK_EXE_PARENT` FOREIGN KEY (`PARENT_ID_`) REFERENCES `act_ru_execution` (`ID_`))
### The error may involve org.activiti.engine.impl.persistence.entity.ExecutionEntityImpl.bulkDeleteExecution-Inline

From what I understand, it seems like this was caused because they were trying to delete from act_ru_execution based on Process Instance ID, meaning that they are trying to delete the parent and child at the same time. Is there any way to help with this, as in, make sure the children is deleted first before the parents get deleted?

The origin source should be at ProcessInstanceResource.java

Full error:

### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`activiti6`.`act_ru_execution`, CONSTRAINT `ACT_FK_EXE_PARENT` FOREIGN KEY (`PARENT_ID_`) REFERENCES `act_ru_execution` (`ID_`))
### The error may involve org.activiti.engine.impl.persistence.entity.ExecutionEntityImpl.bulkDeleteExecution-Inline
### The error occurred while setting parameters
### SQL: delete from ACT_RU_EXECUTION where                 ID_ = ?       or           ID_ = ?
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`activiti6`.`act_ru_execution`, CONSTRAINT `ACT_FK_EXE_PARENT` FOREIGN KEY (`PARENT_ID_`) REFERENCES `act_ru_execution` (`ID_`))] with root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`activiti6`.`act_ru_execution`, CONSTRAINT `ACT_FK_EXE_PARENT` FOREIGN KEY (`PARENT_ID_`) REFERENCES `act_ru_execution` (`ID_`))
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
   at java.lang.reflect.Constructor.newInstance(Unknown Source)
   at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
   at com.mysql.jdbc.Util.getInstance(Util.java:384)
   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1039)
   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4232)
   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4164)
   at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2615)
   at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776)
   at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2838)
   at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082)
   at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1307)
   at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.execute(NewProxyPreparedStatement.java:823)
   at sun.reflect.GeneratedMethodAccessor330.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:55)
   at com.sun.proxy.$Proxy79.execute(Unknown Source)
   at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
   at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
   at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)
   at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:100)
   at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:148)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:161)
   at org.activiti.engine.impl.db.DbSqlSession$BulkCheckedDeleteOperation.execute(DbSqlSession.java:361)
   at org.activiti.engine.impl.db.DbSqlSession.flushRegularDeletes(DbSqlSession.java:868)
   at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:832)
   at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:554)
   at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:193)
   at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:116)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:68)
   at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
   at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
   at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:35)
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:39)
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:34)
   at org.activiti.engine.impl.RuntimeServiceImpl.deleteProcessInstance(RuntimeServiceImpl.java:117)
   at com.activiti.rest.runtime.AbstractProcessInstanceResource.deleteProcessInstance(AbstractProcessInstanceResource.java:134)
   at com.activiti.rest.runtime.ProcessInstanceResource.deleteProcessInstance(ProcessInstanceResource.java:59)
   at com.activiti.rest.runtime.ProcessInstanceResource$$FastClassBySpringCGLIB$$c82699e4.invoke(<generated>)
   at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
   at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
   at com.ryantenney.metrics.spring.TimedMethodInterceptor.invoke(TimedMethodInterceptor.java:48)
   at com.ryantenney.metrics.spring.TimedMethodInterceptor.invoke(TimedMethodInterceptor.java:34)
   at com.ryantenney.metrics.spring.AbstractMetricMethodInterceptor.invoke(AbstractMetricMethodInterceptor.java:59)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
   at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
   at com.activiti.rest.runtime.ProcessInstanceResource$$EnhancerBySpringCGLIB$$6b806c4e.deleteProcessInstance(<generated>)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
   at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
   at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
   at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
   at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
   at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
   at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
   at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
   at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
   at org.springframework.web.servlet.FrameworkServlet.doDelete(FrameworkServlet.java:890)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:654)
   at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
   at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:316)
   at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126)
   at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
   at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
   at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:122)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
   at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
   at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:149)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
   at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:168)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
   at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:48)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
   at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:205)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
   at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:120)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
   at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
   at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:91)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
   at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:53)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
   at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:213)
   at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:176)
   at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
   at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
   at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
   at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2500)
   at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2489)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
   at java.lang.Thread.run(Unknown Source)


Help appreciated. Thank you.
5 REPLIES 5

jbarrez
Star Contributor
Star Contributor
Can you post the process XML and also what method calls you're doing exactly?

chrisx_212
Champ in-the-making
Champ in-the-making
The BPMN is as follows:

<code><?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:xsd="http://www.w3.org/2001/XMLSchema" 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/processdef">
  <process id="two-step-process" name="two-step-process" isExecutable="true">
    <startEvent id="startEvent1" activiti:isInterrupting="false"></startEvent>
    <userTask id="sid-A6F7F796-BE6B-45B9-A994-0BEFD52ADEF3" name="who?
" activiti:formKey="1032">
      <extensionElements>
        <modeler:form-reference-id xmlns:modeler="http://activiti.com/modeler">1032</modeler:form-reference-id>
        <modeler:form-reference-name xmlns:modeler="http://activiti.com/modeler">first-step</modeler:form-reference-name>
      </extensionElements>
    </userTask>
    <sequenceFlow id="sid-333C5162-5526-4183-A651-ADE28CE41507" sourceRef="startEvent1" targetRef="sid-A6F7F796-BE6B-45B9-A994-0BEFD52ADEF3"></sequenceFlow>
    <userTask id="sid-352279E1-34BE-4707-8FF2-B424E6916088" name="yes
" activiti:assignee="1" activiti:formKey="1033">
      <extensionElements>
        <modeler:form-reference-id xmlns:modeler="http://activiti.com/modeler">1033</modeler:form-reference-id>
        <modeler:form-reference-name xmlns:modeler="http://activiti.com/modeler">second-step</modeler:form-reference-name>
        <modeler:activiti-idm-assignee xmlns:modeler="http://activiti.com/modeler">true</modeler:activiti-idm-assignee>
        <modeler:assignee-info-email xmlns:modeler="http://activiti.com/modeler">admin@app.activiti.com</modeler:assignee-info-email>
        <modeler:assignee-info-lastname xmlns:modeler="http://activiti.com/modeler">Administrator</modeler:assignee-info-lastname>
        <modeler:initiator-can-complete xmlns:modeler="http://activiti.com/modeler">false</modeler:initiator-can-complete>
      </extensionElements>
    </userTask>
    <sequenceFlow id="sid-D33C7161-48BF-40C1-A1B7-B3F91C7F1722" sourceRef="sid-A6F7F796-BE6B-45B9-A994-0BEFD52ADEF3" targetRef="sid-352279E1-34BE-4707-8FF2-B424E6916088"></sequenceFlow>
    <endEvent id="sid-21A65A32-B840-4B0A-844A-43977612A240"></endEvent>
    <sequenceFlow id="sid-953A9505-BB1C-4CB8-85D5-2AA8B3395A5C" sourceRef="sid-352279E1-34BE-4707-8FF2-B424E6916088" targetRef="sid-21A65A32-B840-4B0A-844A-43977612A240"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_two-step-process">
    <bpmndi:BPMNPlane bpmnElement="two-step-process" id="BPMNPlane_two-step-process">
      <bpmndi:BPMNShape bpmnElement="startEvent1" id="BPMNShape_startEvent1">
        <omgdc:Bounds height="30.0" width="30.0" x="100.0" y="163.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-A6F7F796-BE6B-45B9-A994-0BEFD52ADEF3" id="BPMNShape_sid-A6F7F796-BE6B-45B9-A994-0BEFD52ADEF3">
        <omgdc:Bounds height="80.0" width="100.0" x="175.0" y="138.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-352279E1-34BE-4707-8FF2-B424E6916088" id="BPMNShape_sid-352279E1-34BE-4707-8FF2-B424E6916088">
        <omgdc:Bounds height="80.0" width="100.0" x="320.0" y="138.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-21A65A32-B840-4B0A-844A-43977612A240" id="BPMNShape_sid-21A65A32-B840-4B0A-844A-43977612A240">
        <omgdc:Bounds height="28.0" width="28.0" x="465.0" y="164.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="sid-333C5162-5526-4183-A651-ADE28CE41507" id="BPMNEdge_sid-333C5162-5526-4183-A651-ADE28CE41507">
        <omgdi:waypoint x="130.0" y="178.0"></omgdi:waypoint>
        <omgdi:waypoint x="175.0" y="178.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-953A9505-BB1C-4CB8-85D5-2AA8B3395A5C" id="BPMNEdge_sid-953A9505-BB1C-4CB8-85D5-2AA8B3395A5C">
        <omgdi:waypoint x="420.0" y="178.0"></omgdi:waypoint>
        <omgdi:waypoint x="465.0" y="178.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-D33C7161-48BF-40C1-A1B7-B3F91C7F1722" id="BPMNEdge_sid-D33C7161-48BF-40C1-A1B7-B3F91C7F1722">
        <omgdi:waypoint x="275.0" y="178.0"></omgdi:waypoint>
        <omgdi:waypoint x="320.0" y="178.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions></code>

The method I'm calling is the Runtime Service's Delete Process Instance.

jbarrez
Star Contributor
Star Contributor
I've tried the following test on the v6 master:

<code>
public class MyUnitTest extends PluggableActivitiTestCase {

@Test
@Deployment(resources = { "org/activiti/test/test.bpmn20.xml" })
public void test() throws Exception {
   org.h2.tools.Server.createWebServer("-web").start();
  
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("two-step-process");
  assertNotNull(processInstance);
 
  runtimeService.deleteProcessInstance(processInstance.getId(), null);
  assertEquals(0, runtimeService.createExecutionQuery().count());
}

}
</code>

And that succeeds.

Is that also what you tried to do?

chrisx_212
Champ in-the-making
Champ in-the-making
Sorry for not replying for long. I came across to another problem based on this.

I ended up modifying the bulkDeleteStatement in DbSqlSession by creating new queries and deleting all child elements first before deleting the parent one. It worked… except that when the command was instead 'Complete Task' instead of 'Cancel Process', things got deleted as well (they flushed the delete commands even as I tried 'Complete Task').

How do we differentiate the command so it's Cancel Process, not Complete Task?

jbarrez
Star Contributor
Star Contributor
Not sure I'm following? How are using triggering complete task instead of cancel … ?