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.