I should have said this is in JBPM 3 and to correct the code examples slightly:
- the task node does have a inner task element in the XML
- in the first example it returns a null TaskInstance not actorId (then a NullPointerException on getActorId())
- in the second example the list of tasks is empty
I'll answer my own question for those that may come across the same problem...
String query = "select ti from org.jbpm.taskmgmt.exe.TaskInstance as ti "+ "where ti.end is not null and ti.token.id = :tokenId"; .... ExecutionContext context = .... JbpmSession session = JbpmSession.getCurrentJbpmSession(); Query query = session.getSession().createQuery(query); query.setLong("tokenId", context.getToken().getId()); List tasks = query.list(); // so something with tasks session.close();
I'm assuming that the TaskInstance is 'ended' before the transition is taken - would be nice to have access to this functionality via TaskMgmtSession