I am trying to retrieve business key for a process instance of a task through task listeners. The event type of my listener is create
. Below is my implementation of task listener:
public void notify(DelegateTask delegateTask) {
LOGGER.info(delegateTask.getProcessInstanceId()); // Prints correct ID
ProcessInstance instance =
Context.getProcessEngineConfiguration()
.getRuntimeService()
.createProcessInstanceQuery()
.processInstanceId(delegateTask.getProcessInstanceId())
.singleResult(); // instance is null
LOGGER.info("Business key: {}", instance.getBusinessKey()); // NPE occurs here
}
But I keep getting NPE in above code. Are create
listeners executed before the creation of process instance?