cancel
Showing results for 
Search instead for 
Did you mean: 

Getting 'Task not found' for task I have just queried

danielbreitner
Champ in-the-making
Champ in-the-making
Hello everyone,

I have encountered a strange error tonight.
We are retrieving UserTasks with a task query and then we call "complete" on each of them.
Tonight, we retrieved a task that we wanted to complete, and it threw the following exception :

org.activiti.engine.ActivitiException: Cannot find task with id 344

My question is : How is it possible, that we get a task through the TaskService that doesn´t exist ?

We are using Activiti 5.10 in a tomcat.


We are retrieving tasks with a Task Query like this:

public List<Task> getTasks(TaskService taskService){

    TaskQuery taskQuery = taskService.createTaskQuery();
    taskQuery.taskAssignee("kermit");
    taskQuery.orderByTaskCreateTime();
    taskQuery.asc();
    return taskQuery.list();
  }

Then we are calling "complete" on the UserTasks:

 for (Task task : waitingTasks) {
taskService.complete(task.getId());
}

The Exception in detail is here:

org.activiti.engine.ActivitiException: Cannot find task with id 344
   at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:50) ~[activiti-engine-5.10.jar:5.10]
   at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:28) ~[activiti-engine-5.10.jar:5.10]
   at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24) [activiti-engine-5.10.jar:5.10]
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42) [activiti-engine-5.10.jar:5.10]
   at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42) [activiti-spring-5.10.jar:na]
   at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130) [spring-tx-3.0.6.RELEASE.jar:3.0.6.RELEASE]
   at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40) [activiti-spring-5.10.jar:na]
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33) [activiti-engine-5.10.jar:5.10]
   at org.activiti.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:144) ~[activiti-engine-5.10.jar:5.10]
   at com.test.TaskCompleter.doExecute(TaskCompleter.java:138) ~[TaskCompleter.class:na]
   at com.test.ActivitiProcessingTask.execute(ActivitiProcessingTask.java:64) [ActivitiProcessingTask.class:na]
   at sun.reflect.GeneratedMethodAccessor1103.invoke(Unknown Source) ~[na:na]
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_26]
   at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_26]


Best regards,

Daniel
6 REPLIES 6

frederikherema1
Star Contributor
Star Contributor
Are there any boundary-timer events defined on the tasks? Are you using the same process-engine (and TaskService) for the query and for the complete?

danielbreitner
Champ in-the-making
Champ in-the-making
Hi,

no - everything is the same, BUT :

I found out that this error relates to "deleted tasks":

1) Task is deleted

2) Task (even though it is deleted) is returned by the query (Caching ??)

3) completing the task fails.


I am sorry that I didn´t mention, that those task have been deleted, but I just got that Info 10 minutes before. The only question I now still have is: Is this a caching issue ?

frederikherema1
Star Contributor
Star Contributor
Activiti only caches on a per-API-call basis. So between 2 api-calls, nothing is cached. When were the tasks deleted? Before the query?

danielbreitner
Champ in-the-making
Champ in-the-making
Hi,

the task was deleted before the query.

The same error occurs when a process flow from one UserTask to another arrives at the second UserTask.
The first UserTask (that doesn´t exist anymore) still comes back when a TaskQuery is used (and provokes the same exception) while the second, newly created UerTask doesn´t come back.

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
the task was deleted before the query.

But was it comitted?

jbarrez
Star Contributor
Star Contributor
I'm having a hard time believing that, it would mean all foundation on which Activiti is built is not happening…
Could you create a unit test demonstrating that problem?