flowable/flowable-engine · error · FlowableObjectNotFoundException

case instance doesn't exist

Error message

case instance  doesn't exist

What it means

After validating inputs, GetCaseVariableInstanceCmd loads the case instance by id via the CaseInstanceEntityManager. If no case instance exists for the given id, it throws FlowableObjectNotFoundException with CaseInstance.class as the type. The message deliberately contains the id followed by ' doesn't exist' (note the double space in the raw concatenation, the id is null/empty in the text when missing).

Source

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

    public GetCaseVariableInstanceCmd(String caseInstanceId, String variableName) {
        this.caseInstanceId = caseInstanceId;
        this.variableName = variableName;
    }

    @Override
    public VariableInstance execute(CommandContext commandContext) {
        if (caseInstanceId == null) {
            throw new FlowableIllegalArgumentException("caseInstanceId is null");
        }
        if (variableName == null) {
            throw new FlowableIllegalArgumentException("variableName is null");
        }

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

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

        return caseInstance.getVariableInstance(variableName, false);
    }
}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Verify the caseInstanceId exists: query the case instance or runtime service first
  2. Check the engine is connected to the same database/schema where the case was created
  3. Confirm the case instance has not been completed/removed (check history service instead)
  4. Correct any id typo or stale id stored by the caller

Example fix

// before
VariableInstance vi = caseService.getVariableInstance(caseInstanceId, "status");
// after
CaseInstance ci = caseService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();
if (ci != null) {
    VariableInstance vi = caseService.getVariableInstance(caseInstanceId, "status");
}
Defensive patterns

Strategy: validation

Validate before calling

boolean exists = caseService.createCaseInstanceQuery().caseInstanceId(id).count() > 0;

Try / catch

try { return caseService.getVariableInstance(caseInstanceId, variableName); } catch (FlowableObjectNotFoundException e) { log.warn("Case instance {} not found", caseInstanceId); return null; }

Prevention

When it happens

Trigger: caseService.getVariableInstance(caseInstanceId, variableName) where caseInstanceId does not match any persisted case instance (already terminated/removed, wrong engine/database, or typo in id).

Common situations: Looking up variables of a case instance that completed and was cleaned up; pointing client at a different database/schema than the engine; copying an id from another environment; historic vs runtime id confusion.

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/8a5f7df4822a9beb. Report an issue: GitHub.