AnsweredAssumed Answered

Problem with setting process variable on a usertask listener

Question asked by marcthomas2012 on Sep 13, 2012
Latest reply on Sep 17, 2012 by marcthomas2012
Hi,

I have a workflow whose first task has a listener attached to it. This listener performs some processing and then attempts to store the result in the activiti process variable. This doesn't work for me because I always get the exception

SEVERE: Error while closing command context
org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Exception while invoking TaskListener: execution 5 doesn't exist
   at org.activiti.engine.impl.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:529)

Whilst debugging through the code I see that the process is started using processInstanceId = workflowManager.startWorkflow(processDefinitionKey, processBean); and the task listener is invoked before the startWorkflow method returns. I can only assume that the execution hasn't fully been setup by the time the user task listener is invoked and therefore the execution ID it is trying to use to save the process variable doesn't completely exist.

The code works fine if the same listener, configured in the same way is attached to a second task.

Any ideas? Does this sound like a defect with Activiti or am I doing something wrong?

The events that I tried to attach the listener to are create and also assignment. Neither work for me.

Thanks
Marc

Outcomes