flowable/flowable-engine · error · FlowableObjectNotFoundException

No history job found with id '

Error message

No history job found with id '

What it means

DeleteHistoryJobCmd fetches the history job with HistoryJobEntityManager.findById and throws FlowableObjectNotFoundException including the requested id when no history job entity exists. The async history job row (ACT_RU_HISTORY_JOB) was not found for that identifier.

Solutions

  1. Query for the history job (createHistoryJobQuery / historyJobEntityManager) before deleting and handle the not-found case gracefully.
  2. Make repeated cleanup idempotent by catching FlowableObjectNotFoundException and continuing.
  3. Confirm async history is enabled and the job hasn't been consumed by the history executor between listing and deletion.
  4. Verify the id against the ACT_RU_HISTORY_JOB table and the engine configuration (database schema) in use.

Example fix

// before
managementService.executeCommand(new DeleteHistoryJobCmd(historyJobId));
// after
try {
    managementService.executeCommand(new DeleteHistoryJobCmd(historyJobId));
} catch (FlowableObjectNotFoundException e) {
    // already executed/purged; nothing to delete
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (managementService.createHistoryJobQuery().jobId(historyJobId).count() == 0) {
    LOGGER.info("History job {} not present; nothing to delete", historyJobId);
    return;
}

Try / catch

try {
    managementService.executeCommand(new DeleteHistoryJobCmd(historyJobId));
} catch (FlowableObjectNotFoundException e) {
    LOGGER.info("History job {} already executed/purged", historyJobId);
}

Prevention

When it happens

Trigger: Deleting a history job after the async executor already executed and removed it; deleting with an id from a completed/failed history job list that has since been purged; wrong id or wrong engine database.

Common situations: History cleanup jobs racing with the async executor; test teardown code deleting history jobs twice; environments where async history was toggled off and old ids no longer resolve; querying with a job id instead of a history job id.

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/4c0a1e3cf084110d. Report an issue: GitHub.

Appendix: source

Thrown at modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/cmd/DeleteHistoryJobCmd.java:76

    protected void sendCancelEvent(HistoryJobEntity jobToDelete) {
        FlowableEventDispatcher eventDispatcher = jobServiceConfiguration.getEventDispatcher();
        if (eventDispatcher != null && eventDispatcher.isEnabled()) {
            eventDispatcher.dispatchEvent(FlowableJobEventBuilder.createEntityEvent(FlowableEngineEventType.JOB_CANCELED, jobToDelete),
                    jobServiceConfiguration.getEngineName());
        }
    }

    protected HistoryJobEntity getJobToDelete(CommandContext commandContext) {
        if (historyJobId == null) {
            throw new FlowableIllegalArgumentException("jobId is null");
        }
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Deleting job {}", historyJobId);
        }

        HistoryJobEntity job = jobServiceConfiguration.getHistoryJobEntityManager().findById(historyJobId);
        if (job == null) {
            throw new FlowableObjectNotFoundException("No history job found with id '" + historyJobId + "'", Job.class);
        }

        return job;
    }

}

View on GitHub (pinned to d6d39ce1c6)