AnsweredAssumed Answered

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

Question asked by danielbreitner on Oct 25, 2012
Latest reply on Oct 29, 2012 by jbarrez
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

Outcomes