flowable/flowable-engine · error · FlowableObjectNotFoundException
task
Error message
task
What it means
After validating inputs, GetTaskDataObjectCmd loads the task via TaskService.getTask(taskId). If no task exists for that id it throws FlowableObjectNotFoundException("task <id> doesn't exist", Task.class), meaning the taskId is well-formed but references no live task.
Source
Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetTaskDataObjectCmd.java:73
this.variableName = variableName;
this.locale = locale;
this.withLocalizationFallback = withLocalizationFallback;
}
@Override
public DataObject execute(CommandContext commandContext) {
if (taskId == null) {
throw new FlowableIllegalArgumentException("taskId is null");
}
if (variableName == null) {
throw new FlowableIllegalArgumentException("variableName is null");
}
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
TaskEntity task = processEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);
if (task == null) {
throw new FlowableObjectNotFoundException("task " + taskId + " doesn't exist", Task.class);
}
DataObject dataObject = null;
VariableInstance variableEntity = task.getVariableInstance(variableName, false);
String localizedName = null;
String localizedDescription = null;
if (variableEntity != null) {
ExecutionEntity executionEntity = CommandContextUtil.getExecutionEntityManager(commandContext).findById(variableEntity.getExecutionId());
while (!executionEntity.isScope()) {
executionEntity = executionEntity.getParent();
}
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(executionEntity.getProcessDefinitionId());
ValuedDataObject foundDataObject = null;
if (executionEntity.getParentId() == null) {
for (ValuedDataObject dataObjectDefinition : bpmnModel.getMainProcess().getDataObjects()) {View on GitHub (pinned to d6d39ce1c6)
Solutions
- Verify the taskId is correct and exists via taskService.createTaskQuery().taskId(id).singleResult() before reading variables
- Handle FlowableObjectNotFoundException in the caller and treat it as 'task gone' (e.g. re-fetch or inform the user)
- Check you are connected to the same process engine/database that owns the task
- If the task may legitimately disappear, catch the exception instead of letting it propagate
Example fix
// before
DataObject d = taskService.getDataObject(taskId, variableName); // throws if task gone
// after
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
if (task != null) {
DataObject d = taskService.getDataObject(taskId, variableName);
} Defensive patterns
Strategy: try-catch
Validate before calling
Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); boolean exists = task != null;
Type guard
boolean taskExists(String taskId) {
return taskId != null
&& taskService.createTaskQuery().taskId(taskId).count() > 0;
} Try / catch
try {
DataObject d = taskService.getDataObject(taskId, variableName);
} catch (FlowableObjectNotFoundException e) {
// task deleted/completed; treat as empty result
d = null;
} Prevention
- Re-query the task instead of caching task ids long-term
- Expect tasks to disappear on completion in shared engines
- Confirm engine/database matches the environment of the taskId
When it happens
Trigger: Calling taskService.getDataObject(taskId, variableName) with a taskId that was deleted, never existed, belongs to a different engine/database, or refers to a completed task removed by history cleanup.
Common situations: Stale task ids cached by the caller; task completed and deleted between lookup and variable read; querying against a test database while using ids from another environment; tenant/db mismatch in multi-engine setups.
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
- No task found for taskId '
- Cannot resume task with id '
- Cannot find task with id ${taskId}
- case instance doesn't exist
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/57a0ad852c4073fb.
Report an issue: GitHub.