0 Replies Latest reply on Jun 1, 2015 5:56 AM by Myank Jain

    Abort process instance issue with jBPM5

    Myank Jain Newbie

      Hello everyone,

       

      I am trying following use case and it is failing with StaleObjectStateException while aborting the process instance.

      1. New process instance (contains one human task node) is created. Assuming human task is assigned to multiple users.
      2. One user whom task is assigned login in portal and claim the task. (Task claimed successfully)
      3. Now, due to some reason user is trying to abort the process instance using ksession.abortProcessInstance(processInstanceId) and failed with following error

       

      2015-06-01 14:41:31,324 [http-nio-8080-exec-4] ERROR [event.def.AbstractFlushingEventListener]  - Could not synchronize database state with session
      org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.task.Task#20953]
        at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1934)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2578)
        at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2478)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2805)
        at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:114)
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:260)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:180)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
        at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:76)
        at org.jbpm.task.service.persistence.TaskLocalTransactionManager.commit(TaskLocalTransactionManager.java:55)
        at org.jbpm.task.service.persistence.TaskPersistenceManager.endTransaction(TaskPersistenceManager.java:107)
        at org.jbpm.task.service.TaskServiceSession.taskOperation(TaskServiceSession.java:455)
        at org.jbpm.task.service.local.LocalTaskService.exit(LocalTaskService.java:133)
        at org.jbpm.process.workitem.wsht.GenericHTWorkItemHandler.abortWorkItem(GenericHTWorkItemHandler.java:206)
        at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.internalAbortWorkItem(JPAWorkItemManager.java:78)
        at org.jbpm.workflow.instance.node.WorkItemNodeInstance.cancel(WorkItemNodeInstance.java:257)
        at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.setState(WorkflowProcessInstanceImpl.java:257)
        at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.setState(WorkflowProcessInstanceImpl.java:269)
        at org.jbpm.process.instance.ProcessRuntimeImpl.abortProcessInstance(ProcessRuntimeImpl.java:371)
        at org.drools.impl.StatefulKnowledgeSessionImpl.abortProcessInstance(StatefulKnowledgeSessionImpl.java:301)
        at org.drools.command.runtime.process.AbortProcessInstanceCommand.execute(AbortProcessInstanceCommand.java:42)
        at org.drools.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36)
        at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:373)
        at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.abortProcessInstance(CommandBasedStatefulKnowledgeSession.java:131)
        at com.xxx.jbpm.workflow.impl.WorkflowManagerImpl.abortWorkflow(WorkflowManagerImpl.java:192)
        at com.xxx.xxx.wsserver.impl.chklist.helpers.IncidentMgmtHelper.closeIncident(IncidentMgmtHelper.java:84)
        at com.xxx.xxx.wsserver.impl.compliance.IncidentMgmtServiceImpl.closeIncident(IncidentMgmtServiceImpl.java:52)
        at com.xxx.xxx.wsserver.controller.compliance.IncidentMgmtController.closeIncident(IncidentMgmtController.java:43)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:746)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:687)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:822)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:655)
        at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)
      


      4. If User try to abort the process instance before claiming and after releasing the human task, process instance aborts successfully.

      5. As suggested by @Maciej in thread https://developer.jboss.org/message/795615, I even tried enabling the human task with setOwningSessionOnly(true) but it couldn't help.

       

      Please anybody could help to resolve this issue?

       

      Thanks,

      Mayank