flowable/flowable-engine · error · ActivitiObjectNotFoundException
No historic process instance found with id
Error message
No historic process instance found with id: ${processInstanceId} What it means
DeleteHistoricProcessInstanceCmd looks up a completed process instance in the ACT_HI_PROCINST history table by id. If no historic row exists with that id, it throws ActivitiObjectNotFoundException carrying HistoricProcessInstance.class as the reference type. History deletion only operates on already-archived instances.
Solutions
- Query historyService.createHistoricProcessInstanceQuery().processInstanceId(id).singleResult() before deleting and skip missing ids.
- Verify the process instance actually completed (endTime set) and ran under a history level that records the instance (audit/activity).
- Wrap the delete in try/catch for ActivitiObjectNotFoundException and treat it as already-deleted in cleanup code.
- Confirm you are connected to the same database/schema where the process ran.
Example fix
// before
historyService.deleteHistoricProcessInstance(processInstanceId);
// after
HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery()
.processInstanceId(processInstanceId).singleResult();
if (hpi != null) {
historyService.deleteHistoricProcessInstance(processInstanceId);
} Defensive patterns
Strategy: validation
Validate before calling
if (historyService.createHistoricProcessInstanceQuery()
.processInstanceId(processInstanceId).count() == 0) {
return; // nothing to delete
} Try / catch
try {
historyService.deleteHistoricProcessInstance(processInstanceId);
} catch (ActivitiObjectNotFoundException e) {
// already deleted or never recorded; treat as success
} Prevention
- Filter cleanup queries with finished() so only deletable history rows are selected
- Ensure historyLevel records instances (>= activity) for processes you plan to purge
- Make history cleanup jobs idempotent by tolerating missing ids
When it happens
Trigger: Calling runtimeService/historyService deleteHistoricProcessInstance(id) (this command) with an id that has no row in the historic process instance table: a bogus id, an id whose history was already deleted, or a process whose history level was configured to 'none' or 'activity' so no historic instance was ever written.
Common situations: Double-deletion in cleanup jobs that don't check for prior removal; processes executed under historyLevel=none; purging history in a different database/environment than the one that recorded it; typos or stale ids cached from another deployment.
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
- No historic process instance found with id:
- Cannot find process definition with id
- Cannot find process instance with id
- Cannot find process instance with id
- Cannot find process instance with id
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/3989ed7995fcec4a.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/DeleteHistoricProcessInstanceCmd.java:48
private static final long serialVersionUID = 1L;
protected String processInstanceId;
public DeleteHistoricProcessInstanceCmd(String processInstanceId) {
this.processInstanceId = processInstanceId;
}
@Override
public Object execute(CommandContext commandContext) {
if (processInstanceId == null) {
throw new ActivitiIllegalArgumentException("processInstanceId is null");
}
// Check if process instance is still running
HistoricProcessInstance instance = commandContext
.getHistoricProcessInstanceEntityManager()
.findHistoricProcessInstance(processInstanceId);
if (instance == null) {
throw new ActivitiObjectNotFoundException("No historic process instance found with id: " + processInstanceId, HistoricProcessInstance.class);
}
if (instance.getEndTime() == null) {
throw new ActivitiException("Process instance is still running, cannot delete historic process instance: " + processInstanceId);
}
commandContext
.getHistoricProcessInstanceEntityManager()
.deleteHistoricProcessInstanceById(processInstanceId);
return null;
}
}
View on GitHub (pinned to d6d39ce1c6)