cancel
Showing results for 
Search instead for 
Did you mean: 

Couldn't get task by processInstanceId

xuemzhan
Champ in-the-making
Champ in-the-making
Hi exports,

1. I created a activitiManager service class wrapped activiti api in SprintMVC service layer.
2. Started a new instance by key definition.
3. Get the current task by instance id which was created in step 2.
4. Submitted the task via formService.submitTaskFormData method.

So here is the problem, steps 2-4 are in the same method, I couldn't get the current task in step 2. But I could get it when I set a break point in debugging mode.

step 2. processInstanceId= activitiManager.instanceProcessByKey(INSTANCE_KEY, currentId.toString(), keyCode, variables);
step 3. curTask = activitiManager.getActiveTaskByProcessInstanceId(processInstanceId);
2 REPLIES 2

jbarrez
Star Contributor
Star Contributor
Probably the method is done in one transaction, hence why the current task can't be found. Split those up in different methods, or change the transactional demarcation.
Or you might have an async step in the beginning and the user task simply doesn't exist yet?

xuemzhan
Champ in-the-making
Champ in-the-making
Thanks Jbarrez, you are right. I have found solution via your advise.