[jBPM] - Terminate Active ProcessInstance in jbpm 5.2 using Local Task Service
by Sridhar J
Sridhar J [https://community.jboss.org/people/sridhar532] created the discussion
"Terminate Active ProcessInstance in jbpm 5.2 using Local Task Service"
To view the discussion, visit: https://community.jboss.org/message/716581#716581
--------------------------------------------------------------
Hi All,
My Process after launching creates three parallel human tasks and stays active in those task for the user to Claim / Complete. Is it possible to Terminate my Active ProcessInstance before the users performs Claim / Complete Operation. Am using Local-JTA in jbpm 5.2 for Launching / Claim my process. When i try to abort the processInstance using* ksession.abortProcessInstance(processInstanceId); am receiving the below error.*
Hibernate: select sessioninf0_.id as id1_0_, sessioninf0_.lastModificationDate as lastModi2_1_0_, sessioninf0_.rulesByteArray as rulesByt3_1_0_, sessioninf0_.startDate as startDate1_0_, sessioninf0_.OPTLOCK as OPTLOCK1_0_ from SessionInfo sessioninf0_ where sessioninf0_.id=?
Hibernate: select processins0_.InstanceId as InstanceId0_0_, processins0_.lastModificationDate as lastModi2_0_0_, processins0_.lastReadDate as lastRead3_0_0_, processins0_.processId as processId0_0_, processins0_.processInstanceByteArray as processI5_0_0_, processins0_.startDate as startDate0_0_, processins0_.state as state0_0_, processins0_.OPTLOCK as OPTLOCK0_0_ from ProcessInstanceInfo processins0_ where processins0_.InstanceId=?
Hibernate: select workitemin0_.workItemId as workItemId2_0_, workitemin0_.creationDate as creation2_2_0_, workitemin0_.name as name2_0_, workitemin0_.processInstanceId as processI4_2_0_, workitemin0_.state as state2_0_, workitemin0_.OPTLOCK as OPTLOCK2_0_, workitemin0_.workItemByteArray as workItem7_2_0_ from WorkItemInfo workitemin0_ where workitemin0_.workItemId=?
Hibernate: select * from ( select task0_.id as id17_, task0_.allowedToDelegate as allowedT2_17_, task0_.taskInitiator_id as taskIni25_17_, task0_.priority as priority17_, task0_.activationTime as activati4_17_, task0_.actualOwner_id as actualO26_17_, task0_.createdBy_id as createdBy27_17_, task0_.createdOn as createdOn17_, task0_.documentAccessType as document6_17_, task0_.documentContentId as document7_17_, task0_.documentType as document8_17_, task0_.expirationTime as expirati9_17_, task0_.faultAccessType as faultAc10_17_, task0_.faultContentId as faultCo11_17_, task0_.faultName as faultName17_, task0_.faultType as faultType17_, task0_.outputAccessType as outputA14_17_, task0_.outputContentId as outputC15_17_, task0_.outputType as outputType17_, task0_.parentId as parentId17_, task0_.previousStatus as previou18_17_, task0_.processId as processId17_, task0_.processInstanceId as process20_17_, task0_.processSessionId as process21_17_, task0_.skipable as skipable17_, task0_.status as status17_, task0_.workItemId as workItemId17_ from Task task0_ where task0_.workItemId=? ) where rownum <= ?
Feb 14, 2012 9:42:53 PM org.drools.persistence.SingleSessionCommandService rollbackTransaction
SEVERE: Could not commit session
java.lang.RuntimeException: javax.persistence.TransactionRequiredException: No active JTA transaction on joinTransaction call
at org.jbpm.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:990)
at org.jbpm.task.service.TaskServiceSession.taskOperation(TaskServiceSession.java:433)
at org.jbpm.task.service.local.LocalTaskService.skip(LocalTaskService.java:220)
at com.jpmorgan.tss.dm.jbpm.util.SyncWSHumanTaskHandler.abortWorkItem(SyncWSHumanTaskHandler.java:296)
at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.internalAbortWorkItem(JPAWorkItemManager.java:76)
at org.jbpm.workflow.instance.node.WorkItemNodeInstance.cancel(WorkItemNodeInstance.java:249)
at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.setState(WorkflowProcessInstanceImpl.java:257)
at org.jbpm.process.instance.ProcessRuntimeImpl.abortProcessInstance(ProcessRuntimeImpl.java:362)
at org.drools.impl.StatefulKnowledgeSessionImpl.abortProcessInstance(StatefulKnowledgeSessionImpl.java:287)
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:345)
at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.abortProcessInstance(CommandBasedStatefulKnowledgeSession.java:131)
at com.jpmorgan.tss.dm.jbpm.core.test.ComplexProcessTest.abortProcess(ComplexProcessTest.java:316)
at org.apache.jsp.pages.jbpm.testTaskComplete_jsp._jspService(testTaskComplete_jsp.java:72)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.persistence.TransactionRequiredException: No active JTA transaction on joinTransaction call
at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:458)
at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:431)
at org.jbpm.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:986)
... 32 more
java.lang.RuntimeException: javax.persistence.TransactionRequiredException: No active JTA transaction on joinTransaction call
at org.jbpm.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:990)
at org.jbpm.task.service.TaskServiceSession.taskOperation(TaskServiceSession.java:433)
at org.jbpm.task.service.local.LocalTaskService.skip(LocalTaskService.java:220)
at com.jpmorgan.tss.dm.jbpm.util.SyncWSHumanTaskHandler.abortWorkItem(SyncWSHumanTaskHandler.java:296)
at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.internalAbortWorkItem(JPAWorkItemManager.java:76)
at org.jbpm.workflow.instance.node.WorkItemNodeInstance.cancel(WorkItemNodeInstance.java:249)
at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.setState(WorkflowProcessInstanceImpl.java:257)
at org.jbpm.process.instance.ProcessRuntimeImpl.abortProcessInstance(ProcessRuntimeImpl.java:362)
at org.drools.impl.StatefulKnowledgeSessionImpl.abortProcessInstance(StatefulKnowledgeSessionImpl.java:287)
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:345)
at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.abortProcessInstance(CommandBasedStatefulKnowledgeSession.java:131)
at com.jpmorgan.tss.dm.jbpm.core.test.ComplexProcessTest.abortProcess(ComplexProcessTest.java:316)
at org.apache.jsp.pages.jbpm.testTaskComplete_jsp._jspService(testTaskComplete_jsp.java:72)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
*Is it possible to abort the processInstance using any other way ?*
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/716581#716581]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 11 months
[jBPM] - Re: jBPM5 - How to abort a already running ProcessInstance?
by scurvo
scurvo [https://community.jboss.org/people/scurvo] created the discussion
"Re: jBPM5 - How to abort a already running ProcessInstance?"
To view the discussion, visit: https://community.jboss.org/message/716564#716564
--------------------------------------------------------------
Hi,
The way I solved it and according to my problem was:
1 - Create a Work Item handler and the work item with abort methods:
public class PrintWorkItemHandler extends MyWorkItemHandler {
public Printer2 p;
protected Date startTime;
protected Date endTime;
class printThread extends Thread {
protected long wiID;
public printThread(long wiID) {
this.wiID = wiID;
}
public void run() {
startTime = new Date();
p = new Printer2();
p.printAlot("adasd");
// notify manager that work item has been completed
mng.completeWorkItem(wiID, null);
endTime = new Date();
System.out.println("PRINT ENDED and took " +
JBPMUtil.dateDiff(startTime, endTime));
}
}
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
super.addWorkItem(workItem);
super.setWorkItemManager(manager);
new printThread(workItem.getId()).start();
}
public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {
System.out.println("ABORTED");
p.stop = true;
manager.abortWorkItem(workItem.getId());
}
}
2 - When i want a workItem to finish i do:
mng.completeWorkItem(wiID, null); to complete ir
or
manager.abortWorkItem(workItem.getId()); to abort it
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/716564#716564]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 11 months