flowable/flowable-engine · error · ActivitiObjectNotFoundException
No task found for taskId ''
Error message
No task found for taskId ''
What it means
GetTaskFormCmd looks up the task by taskId via the task entity manager and throws ActivitiObjectNotFoundException when findTaskById returns null. This means the taskId passed to the TaskService.getTaskForm API does not correspond to any persisted task row. The exception carries Task.class so callers can detect the missing entity type.
Source
Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetTaskFormCmd.java:45
/**
* @author Tom Baeyens
*/
public class GetTaskFormCmd implements Command<TaskFormData>, Serializable {
private static final long serialVersionUID = 1L;
protected String taskId;
public GetTaskFormCmd(String taskId) {
this.taskId = taskId;
}
@Override
public TaskFormData execute(CommandContext commandContext) {
TaskEntity task = commandContext
.getTaskEntityManager()
.findTaskById(taskId);
if (task == null) {
throw new ActivitiObjectNotFoundException("No task found for taskId '" + taskId + "'", Task.class);
}
if (task.getTaskDefinition() != null) {
TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
if (taskFormHandler == null) {
throw new ActivitiException("No taskFormHandler specified for task '" + taskId + "'");
}
return taskFormHandler.createTaskForm(task);
} else {
// Standalone task, no TaskFormData available
return null;
}
}
}
View on GitHub (pinned to d6d39ce1c6)
Solutions
- Verify the taskId with taskService.createTaskQuery().taskId(taskId).singleResult() before requesting the form.
- Confirm you are using the actual task id, not the execution or process instance id.
- Check you are connected to the same database/engine that owns the task.
- Catch ActivitiObjectNotFoundException and surface a 'task no longer exists' message to the user.
Example fix
// before
TaskFormData form = taskService.getTaskForm(staleTaskId);
// after
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
if (task != null) {
TaskFormData form = taskService.getTaskForm(taskId);
} else {
logger.warn("Task {} no longer exists, refreshing task list", taskId);
} Defensive patterns
Strategy: validation
Validate before calling
boolean exists = taskService.createTaskQuery().taskId(taskId).count() > 0;
if (!exists) throw new IllegalStateException("Task " + taskId + " not found"); Try / catch
try {
TaskFormData form = taskService.getTaskForm(taskId);
} catch (ActivitiObjectNotFoundException e) {
// e.getObjectClass() == Task.class: task missing; refresh task list
} Prevention
- Always obtain task ids from taskService query results, never hard-code them.
- Refresh cached task ids after task completion events.
- Distinguish task ids from execution/process instance ids in your DTOs.
When it happens
Trigger: Calling taskService.getTaskForm(taskId) with an id for a task that was deleted, completed (and removed by history level cleanup), never created, or with an id belonging to a different engine/database.
Common situations: Stale task ids cached in a UI after the task was completed; calling with an execution id instead of a task id; multi-database setups where the id belongs to another schema; tests using fabricated ids like "12345".
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- Task '' not found
- Cannot resume task with id '
- Cannot find task with id ${taskId}
- task ${taskId} doesn't exist
- Cannot find plan item '<planItemId>' in case definition with
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/dd9b17170dcc5f80.
Report an issue: GitHub.