I did this in a project:
| StatefulKnowledgeSession session = |
| JPAKnowledgeService.newStatefulKnowledgeSession(gewKnowledgeBase(), null, getEnvoriment()); |
TaskServiceSession taskServiceSession = taskService.createSession();
taskServiceSession.setTransactionType(Constants.TRANSACTION_TYPE);
org.jbpm.task.TaskService client = new LocalTaskService(taskServiceSession);
SyncWSHumanTaskHandler handler = new SyncWSHumanTaskHandler(client, session);
handler.setLocal(true);
handler.connect();
session.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
I did a library that modularize this, to handle close resources etc.
Hope it helps.