cancel
Showing results for 
Search instead for 
Did you mean: 

COMPLETE USER TASK USING SERVICE TASK

himaakishore
Champ in-the-making
Champ in-the-making
Hi,

i'm getting the below error when I'm trying to auto complete a user task(using service task) through a timer.

Error:

06:16:22,082 [pool-1-thread-2] WARN  org.activiti.engine.delegate.event.impl.ActivitiEventSupport  - Exception while executing event-listener, which was ignored
org.activiti.engine.ActivitiObjectNotFoundException: execution 275162 doesn't exist

Code:
public class WorkFlowAutoProcessing implements JavaDelegate {

   @Autowired
   protected TaskService taskService;
   public void execute(DelegateExecution execution) throws Exception {
   
      String currentUserTaskName = (String) execution.getVariable(WorkFlowConstants.CURRENT_USER_TASK_NAME);
      TaskQuery taskQuery = taskService.createTaskQuery().taskDefinitionKey(currentUserTaskName);
      taskQuery = taskService.createTaskQuery()
            .processInstanceId(execution.getProcessInstanceId());
      Task task = taskQuery.list().get(0);
         Map<String, Object> variables=new HashMap<String, Object>();
         String remarks = "Auto Processed on "+new Date();
         variables.put("Remarks",remarks);
         taskService.complete(task.getId(), variables);
         }
   }

}


Is this a right approach? or is there any other way to handle it?

Thanks in advance.
1 REPLY 1

yvoswillens
Champ in-the-making
Champ in-the-making
Hi,

looks there's no execution with the given id.
Perhaps you could wrap code into a unit test?

Regards,

Yvo