flowable/flowable-engine · error · FlowableObjectNotFoundException
task doesn't exist
Error message
task ${taskId} doesn't exist What it means
GetTaskVariableCmd throws FlowableObjectNotFoundException (with Task.class) when the task service returns no TaskEntity for the given taskId. The variable lookup cannot proceed without an existing task.
Solutions
- Verify existence first: cmmnTaskService.createTaskQuery().taskId(taskId).singleResult()
- For completed tasks use cmmnHistoryService.createHistoricTaskInstanceQuery() and historic variable queries
- Make sure the id comes from the CMMN engine's task service, not the BPMN one
- Handle the FlowableObjectNotFoundException in callers that accept user-supplied task ids
Example fix
// before
Object value = cmmnTaskService.getVariable(taskId, varName); // throws if task gone
// after
Task t = cmmnTaskService.createTaskQuery().taskId(taskId).singleResult();
Object value = (t != null)
? cmmnTaskService.getVariable(taskId, varName)
: cmmnHistoryService.createHistoricVariableInstanceQuery().taskId(taskId).variableName(varName).singleValue(); Defensive patterns
Strategy: try-catch
Validate before calling
Task t = cmmnTaskService.createTaskQuery().taskId(taskId).singleResult();
if (t == null) {
throw new IllegalArgumentException("No CMMN task for id " + taskId);
} Type guard
boolean taskExists(String taskId) {
return taskId != null && cmmnTaskService.createTaskQuery().taskId(taskId).count() > 0;
} Try / catch
try {
Object value = cmmnTaskService.getVariable(taskId, variableName);
} catch (FlowableObjectNotFoundException e) {
// Task.class entity missing: fall back to historic variable query or return 404
} Prevention
- Check task existence with a query before variable reads on user-supplied ids
- Route completed tasks to historic variable queries
- Keep CMMN and BPMN task id namespaces separate in clients
When it happens
Trigger: Calling cmmnTaskService.getVariable(taskId, name) with a taskId that has no matching CMMN task — wrong id, task completed and moved to history, or id from the BPMN engine instead of CMMN.
Common situations: Cross-engine id confusion (BPMN taskService vs cmmnTaskService); querying after the case/task was terminated and removed; stale ids cached in an external UI across environment switches.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Task not found with id
- Cannot find case definition for id:
- Cannot find case definition with id
- Cannot find case definition with id
- Cannot find case instance for id
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/f2fa938614692d74.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetTaskVariableCmd.java:57
this.taskId = taskId;
this.variableName = variableName;
this.isLocal = isLocal;
}
@Override
public Object execute(CommandContext commandContext) {
if (taskId == null) {
throw new FlowableIllegalArgumentException("taskId is null");
}
if (variableName == null) {
throw new FlowableIllegalArgumentException("variableName is null");
}
CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
TaskEntity task = cmmnEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);
if (task == null) {
throw new FlowableObjectNotFoundException("task " + taskId + " doesn't exist", Task.class);
}
Object value;
if (isLocal) {
value = task.getVariableLocal(variableName, false);
} else {
value = task.getVariable(variableName, false);
}
return value;
}
}
View on GitHub (pinned to d6d39ce1c6)