hua zhong [
https://community.jboss.org/people/ghuazh] created the discussion
"jBPM5.3 LocalHumanTaskService"
To view the discussion, visit:
https://community.jboss.org/message/739520#739520
--------------------------------------------------------------
Hi, all
I'm using jBPM5.3 final in our project, and try to use local human task handler.
I got too many problems need someone help me.
1. to start a process:
Map<String, Object> params = new HashMap<String, Object>();
params.put("act_rule_launcher", "krisv");
params.put("act_rule_dept_manager", "john");
params.put("act_checker", "mary");
params.put("act_approver", "tracy");
StatefulKnowledgeSession ksession = BPM.getBPMService().getSession("com.tmt");
HTWorkItemHandler handler = new HTWorkItemHandler(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
ksession.startProcess("com.tmt.ProjectPlanApproval", params);
HTWorkItemHandler is a local work item extends AbstractHTWorkItemHandler.
Exception:
0 03/06 18:06:18,379[UIThread [1gpcqnco5rnu6n5d7u3otffrb]] ERROR
hibernate.transaction.JDBCTransaction.toggleAutoCommit - Could not toggle autocommit
java.sql.SQLException: autocommit is not allowed on a resource enlisted in a global
transaction
at
bitronix.tm.resource.jdbc.JdbcConnectionHandle.setAutoCommit(JdbcConnectionHandle.java:177)
at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
I guess maybe I need to change persistence.xml to use JTA?
<persistence-unit name="org.jbpm.task">
change to:
<persistence-unit name="org.jbpm.task" transaction-type="JTA">
After that, It's ok. but soon I got the 2nd problem, see below.
2. complete a task
HTTaskService service = BPM.getHumanTaskService().getTaskService();
List<TaskSummary> tasks =
service.getTasksAssignedAsPotentialOwner(userId,"en-UK");
if(tasks.isEmpty()){
return;
}
for(int i =0;i<tasks.size();i++){
TaskSummary task = tasks.get(i);
System.out.println(userId+">>"+task.getId()+task.getName());
}
long taskId = tasks.get(0).getId();
service.start(taskId, userId);
service.complete(taskId, userId,null);
HTTaskService is a taskservice extends LocalTaskService.
BPM.getHumanTaskService().getTaskService() will return a new HTTaskService from a
org.jbpm.task.service.TaskService.
in my application only one org.jbpm.task.service.TaskService will created, every
HTTaskService whil use it.
service.start is ok.
but when service complete, it brings a new exception:
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.drools.persistence.jpa.JpaPersistenceContextManager.beginCommandScopedEntityManager(JpaPersistenceContextManager.java:83)
at
org.jbpm.persistence.processinstance.JPAProcessInstanceManager.getProcessInstance(JPAProcessInstanceManager.java:75)
at
org.jbpm.process.instance.ProcessRuntimeImpl.getProcessInstance(ProcessRuntimeImpl.java:204)
at
org.drools.common.AbstractWorkingMemory.getProcessInstance(AbstractWorkingMemory.java:1100)
at
org.drools.impl.StatefulKnowledgeSessionImpl.getProcessInstance(StatefulKnowledgeSessionImpl.java:297)
at
org.drools.persistence.jpa.processinstance.JPAWorkItemManager.completeWorkItem(JPAWorkItemManager.java:117)
at
com.sg.bpm.service.task.HTWorkItemHandler$TaskCompletedHandler.execute(HTWorkItemHandler.java:165)
at
org.jbpm.task.service.local.LocalTaskService$SimpleEventTransport.trigger(LocalTaskService.java:307)
at
org.jbpm.task.event.MessagingTaskEventListener.taskCompleted(MessagingTaskEventListener.java:73)
at org.jbpm.task.event.TaskEventSupport.fireTaskCompleted(TaskEventSupport.java:46)
at
org.jbpm.task.service.TaskServiceSession.postTaskCompleteOperation(TaskServiceSession.java:502)
at
org.jbpm.task.service.TaskServiceSession.taskOperation(TaskServiceSession.java:468)
at org.jbpm.task.service.local.LocalTaskService.complete(LocalTaskService.java:80)
I test task client of HornetQ, everything is ok. but how to use local service?
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/739520#739520]
Start a new discussion in jBPM at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]