flowable/flowable-engine · error · FlowableObjectNotFoundException

No case instance found for id

Error message

No case instance found for id 

What it means

GetHistoricStageOverviewCmd.execute looks up the historic case instance via HistoricCaseInstanceEntityManager.findById(caseInstanceId). If none is found it throws FlowableObjectNotFoundException naming the id, because a stage overview can only be built for an existing historic case instance.

Source

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

/**
 * @author Tijs Rademakers
 */
public class GetHistoricStageOverviewCmd implements Command<List<StageResponse>>, Serializable {

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

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

    @Override
    public List<StageResponse> execute(CommandContext commandContext) {
        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
        HistoricCaseInstanceEntity caseInstance = cmmnEngineConfiguration.getHistoricCaseInstanceEntityManager().findById(caseInstanceId);
        if (caseInstance == null) {
            throw new FlowableObjectNotFoundException("No case instance found for id " + caseInstanceId, HistoricCaseInstanceEntity.class);
        }

        HistoricPlanItemInstanceEntityManager planItemInstanceEntityManager = cmmnEngineConfiguration.getHistoricPlanItemInstanceEntityManager();
        List<HistoricPlanItemInstance> planItemInstances = planItemInstanceEntityManager.findByCriteria(new HistoricPlanItemInstanceQueryImpl()
            .planItemInstanceCaseInstanceId(caseInstanceId)
            .planItemInstanceDefinitionTypes(Arrays.asList(PlanItemDefinitionType.STAGE, PlanItemDefinitionType.MILESTONE))
            .orderByEndedTime().asc());

        // Filter out the states that shouldn't be returned in the overview
        planItemInstances.removeIf(planItemInstance -> PlanItemInstanceState.INTERMEDIARY_STATES.contains(planItemInstance.getState()));

        CmmnDeploymentManager deploymentManager = cmmnEngineConfiguration.getDeploymentManager();
        CaseDefinition caseDefinition = deploymentManager.findDeployedCaseDefinitionById(caseInstance.getCaseDefinitionId());
        CmmnModel cmmnModel = deploymentManager.resolveCaseDefinition(caseDefinition).getCmmnModel();
        List<Stage> stages = cmmnModel.getPrimaryCase().getPlanModel().findPlanItemDefinitionsOfType(Stage.class, true);
        List<Milestone> milestones = cmmnModel.getPrimaryCase().getPlanModel().findPlanItemDefinitionsOfType(Milestone.class, true);
        
        List<OverviewElement> overviewElements = new ArrayList<>();

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Confirm the case instance is completed/archived (query historic case instance first) and the id is correct.
  2. If the case is still running, use the runtime plan item/stage APIs instead.
  3. Check history cleanup configuration/cleanup jobs have not removed the instance.

Example fix

// before
List<StageResponse> stages = getStageOverview(caseInstanceId);
// after
HistoricCaseInstance hci = cmmnHistoryService.createHistoricCaseInstanceQuery()
    .caseInstanceId(caseInstanceId).singleResult();
List<StageResponse> stages = hci != null
    ? getStageOverview(caseInstanceId)
    : Collections.emptyList();
Defensive patterns

Strategy: try-catch

Validate before calling

HistoricCaseInstance c = cmmnHistoryService.createHistoricCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();
if (c == null) { throw new NotFoundException("No historic case instance " + caseInstanceId); }

Type guard

boolean historicCaseExists = cmmnHistoryService.createHistoricCaseInstanceQuery().caseInstanceId(id).count() > 0;

Try / catch

try { return stageOverviewService.getStageOverview(caseInstanceId); } catch (FlowableObjectNotFoundException e) { log.warn("Historic case instance not found: {}", caseInstanceId); return Collections.emptyList(); }

Prevention

When it happens

Trigger: Calling the command with a caseInstanceId that does not exist in historic case instance storage: not-yet-completed case (still runtime), deleted history, wrong engine, or a mistyped id.

Common situations: Requesting a stage overview before the case finished (data lives in runtime tables until completion), history level configured too low, stale ids after history cleanup jobs.

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/4436c9cfb0524450. Report an issue: GitHub.