flowable/flowable-engine · error · FlowableObjectNotFoundException

No case instance found for id =

Error message

No case instance found for id = '${caseInstanceId}'.

What it means

Thrown by SetCaseInstanceBusinessStatusCmd.execute when no CMMN case instance exists for the given id. Flowable looks up the CaseInstanceEntity via the entity manager before updating its business status; if findById returns null it raises FlowableObjectNotFoundException with CaseInstance.class as the referenced type. It signals that the target case instance does not exist (or was already deleted).

Solutions

  1. Verify the caseInstanceId with cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(id).singleResult() before setting the status
  2. Confirm you are not confusing a BPMN process instance id with a CMMN case instance id
  3. Check you are connected to the same database/schema where the case instance was created
  4. If the case may no longer exist, catch FlowableObjectNotFoundException and treat it as an idempotent no-op or propagate a 404

Example fix

// before
cmmnRuntimeService.setCaseInstanceBusinessStatus(caseInstanceId, "ACTIVE");
// after
if (cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).count() > 0) {
    cmmnRuntimeService.setCaseInstanceBusinessStatus(caseInstanceId, "ACTIVE");
} else {
    logger.warn("Case instance {} not found, skipping business status update", caseInstanceId);
}
Defensive patterns

Strategy: validation

Validate before calling

boolean exists = cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).count() > 0;
if (!exists) { throw new IllegalArgumentException("Unknown caseInstanceId: " + caseInstanceId); }

Type guard

boolean isValidCaseInstance(String id) { return id != null && !id.isEmpty() && cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(id).count() > 0; }

Try / catch

try {
    cmmnRuntimeService.setCaseInstanceBusinessStatus(caseInstanceId, status);
} catch (FlowableObjectNotFoundException e) {
    throw new NotFoundException("Case instance not found: " + caseInstanceId, e);
}

Prevention

When it happens

Trigger: Calling CmmnRuntimeService.setCaseInstanceBusinessStatus(caseInstanceId, businessStatus) with an id that does not match any running or completed case instance.

Common situations: Passing a processInstanceId (BPMN) instead of a caseInstanceId; using a stale id after the case instance ended and was removed; typos or truncated ids from external storage; querying a different database/schema than the one the case was created in.

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/0451b1146d0855b6. Report an issue: GitHub.

Appendix: source

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

    private final String caseInstanceId;
    private final String businessStatus;

    public SetCaseInstanceBusinessStatusCmd(String caseInstanceId, String businessStatus) {
        if (caseInstanceId == null || caseInstanceId.isEmpty()) {
            throw new FlowableIllegalArgumentException("The case instance id is mandatory, but '" + caseInstanceId + "' has not been provided.");
        }

        this.caseInstanceId = caseInstanceId;
        this.businessStatus = businessStatus;
    }

    @Override
    public Void execute(CommandContext commandContext) {
        CaseInstanceEntityManager caseInstanceEntityManager = CommandContextUtil.getCaseInstanceEntityManager(commandContext);
        CaseInstanceEntity caseInstanceEntity = caseInstanceEntityManager.findById(caseInstanceId);
        if (caseInstanceEntity == null) {
            throw new FlowableObjectNotFoundException("No case instance found for id = '" + caseInstanceId + "'.", CaseInstance.class);
        }

        caseInstanceEntityManager.updateCaseInstanceBusinessStatus(caseInstanceEntity, businessStatus);

        return null;
    }
}

View on GitHub (pinned to d6d39ce1c6)