flowable/flowable-engine · error · FlowableObjectNotFoundException

case instance doesn't exist

Error message

case instance  doesn't exist

What it means

GetCaseVariableInstancesCmd loads the case instance by id using the CaseInstanceEntityManager. When findById returns null, meaning no runtime case instance matches the id, Flowable throws FlowableObjectNotFoundException typed to CaseInstance. The double space in 'case instance doesn't exist' reflects the message being built without embedding the id in this variant.

Source

Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetCaseVariableInstancesCmd.java:48

    
    protected String caseInstanceId;

    public GetCaseVariableInstancesCmd(String caseInstanceId) {
        this.caseInstanceId = caseInstanceId;
    }

    @Override
    public Map<String, VariableInstance> execute(CommandContext commandContext) {

        // Verify existence of execution
        if (caseInstanceId == null) {
            throw new FlowableIllegalArgumentException("caseInstanceId is null");
        }

        CaseInstanceEntity caseInstance = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceId);

        if (caseInstance == null) {
            throw new FlowableObjectNotFoundException("case instance " + caseInstanceId + " doesn't exist", CaseInstance.class);
        }

        return caseInstance.getVariableInstances();
    }
}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Confirm the case instance exists via a caseInstanceQuery before fetching variables
  2. Use the history service (HistoricCaseInstance) if the case already completed
  3. Verify engine datasource matches where the case instance was created
  4. Re-check/correct the caseInstanceId value

Example fix

// before
Map<String, VariableInstance> vars = caseService.getVariableInstances(caseInstanceId);
// after
CaseInstance ci = caseService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();
if (ci == null) {
    // fall back to history
    HistoricCaseInstance hci = historyService.createHistoricCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();
} else {
    Map<String, VariableInstance> vars = caseService.getVariableInstances(caseInstanceId);
}
Defensive patterns

Strategy: validation

Validate before calling

if (caseService.createCaseInstanceQuery().caseInstanceId(id).count() == 0) { /* not found path */ }

Try / catch

try { return caseService.getVariables(caseInstanceId); } catch (FlowableObjectNotFoundException e) { return Collections.emptyMap(); }

Prevention

When it happens

Trigger: caseService.getVariables(caseInstanceId) with an id of a case instance that does not exist in the runtime tables (completed, deleted, different DB, or wrong id).

Common situations: Querying variables after case completion (runtime data gone); multi-environment id mix-ups; pointing the API at a fresh/cleared database; stale cached ids in a frontend.

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


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/c4da72d4c9728002. Report an issue: GitHub.