flowable/flowable-engine · error · FlowableObjectNotFoundException

No historic case instance found with id:

Error message

No historic case instance found with id: 

What it means

After the null check, the command loads the historic case instance by id via HistoricCaseInstanceEntityManager.findById. If none is found it throws FlowableObjectNotFoundException with type HistoricCaseInstance. The id never existed in history, history was not recorded (history level too low), or the record was already deleted.

Source

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

    private static final long serialVersionUID = 1L;
    
    protected String caseInstanceId;

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

    @Override
    public Object execute(CommandContext commandContext) {
        if (caseInstanceId == null) {
            throw new FlowableIllegalArgumentException("caseInstanceId is null");
        }
        // Check if case instance is still running
        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
        HistoricCaseInstanceEntity instance = cmmnEngineConfiguration.getHistoricCaseInstanceEntityManager().findById(caseInstanceId);

        if (instance == null) {
            throw new FlowableObjectNotFoundException("No historic case instance found with id: " + caseInstanceId, HistoricCaseInstance.class);
        }
        if (instance.isDeleted()) {
            return null;
        }


        if (instance.getEndTime() == null) {
            throw new FlowableException("Case instance is still running, cannot delete " + instance);
        }

        cmmnEngineConfiguration.getCmmnHistoryManager().recordHistoricCaseInstanceDeleted(caseInstanceId, instance.getTenantId());

        return null;
    }

}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Verify existence with historyService.createHistoricCaseInstanceQuery().caseInstanceId(id).singleResult() before deleting
  2. Ensure the engine history level records case instances (configure cmmn history level to AUDIT/FULL)
  3. Make deletion idempotent: catch FlowableObjectNotFoundException and log instead of failing
  4. Confirm the id is from the same environment/database

Example fix

// before
historyService.deleteHistoricCaseInstance(caseId);
// after
HistoricCaseInstance hci = historyService.createHistoricCaseInstanceQuery().caseInstanceId(caseId).singleResult();
if (hci != null) {
    historyService.deleteHistoricCaseInstance(caseId);
}
Defensive patterns

Strategy: validation

Validate before calling

HistoricCaseInstance hci = historyService.createHistoricCaseInstanceQuery().caseInstanceId(id).singleResult();
if (hci == null) { log.info("no historic case instance {}", id); return; }

Try / catch

try { historyService.deleteHistoricCaseInstance(id); }
catch (FlowableObjectNotFoundException e) { if (e.getObjectClass() != null && HistoricCaseInstance.class.equals(e.getObjectClass())) { log.info("already deleted: {}", id); } else throw e; }

Prevention

When it happens

Trigger: Calling CmmnHistoryService.deleteHistoricCaseInstance(id) with an unknown id, an id from another engine/database, or after the history row was already purged by cleanup.

Common situations: History level set to NONE/ACTIVITY so case history is never written; retention jobs deleting rows before app code; cross-environment data (test id used against prod).

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


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