flowable/flowable-engine · error · ActivitiObjectNotFoundException
Could not find a deployment with id
Error message
Could not find a deployment with id '<deploymentId>'.
What it means
ActivitiObjectNotFoundException thrown by DeploymentManager.removeDeployment when the deployment id passed to RepositoryService.deleteDeployment does not exist. The engine looks up the DeploymentEntity first; null triggers this error before any cascade deletion begins, so nothing is removed.
Solutions
- Check existence first: repositoryService.createDeploymentQuery().deploymentId(id).singleResult() != null
- Skip deletion (or log-and-continue) when the deployment is already absent — the end state (not deployed) is already achieved
- List valid deployments via repositoryService.createDeploymentQuery().list() to find the correct id
- Verify the delete runs against the same database the deployment was made in
Example fix
// before
repositoryService.deleteDeployment(deploymentId, true); // throws if already gone
// after
if (repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult() != null) {
repositoryService.deleteDeployment(deploymentId, true);
} Defensive patterns
Strategy: validation
Validate before calling
if (repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult() == null) {
return; // already deleted — treat delete as idempotent
} Try / catch
try {
repositoryService.deleteDeployment(deploymentId, true);
} catch (ActivitiObjectNotFoundException e) {
log.info("Deployment {} already removed", deploymentId);
} Prevention
- Treat deleteDeployment as non-idempotent; check existence first or catch the exception
- Never reuse ids copied from logs or other environments
- Run cleanup against a verified datasource
When it happens
Trigger: Calling repositoryService.deleteDeployment(deploymentId) or deleteDeployment(deploymentId, cascade) with an id that was never created, already deleted, or belongs to another database/tenant.
Common situations: Deleting the same deployment twice, ids from a different environment's database, truncated ids from logs, or cleanup scripts running against the wrong schema.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Could not find a deployment with id
- Could not find a deployment with id ''.
- Could not find a deployment with id '" + deploymentId + "'.
- Could not find a deployment with id
- Comment with id ' ' doesn't exists.
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/d375bf206d53f5ac.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/persistence/deploy/DeploymentManager.java:207
deployment.setNew(false);
deploy(deployment, null);
cachedProcessDefinition = processDefinitionCache.get(processDefinitionId);
if (cachedProcessDefinition == null) {
throw new ActivitiException("deployment '" + deploymentId + "' didn't put process definition '" + processDefinitionId + "' in the cache");
}
}
return cachedProcessDefinition;
}
public void removeDeployment(String deploymentId, boolean cascade) {
DeploymentEntityManager deploymentEntityManager = Context
.getCommandContext()
.getDeploymentEntityManager();
DeploymentEntity deployment = deploymentEntityManager.findDeploymentById(deploymentId);
if (deployment == null) {
throw new ActivitiObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.", DeploymentEntity.class);
}
// Remove any process definition from the cache
List<ProcessDefinition> processDefinitions = new ProcessDefinitionQueryImpl(Context.getCommandContext())
.deploymentId(deploymentId)
.list();
FlowableEventDispatcher eventDispatcher = Context.getProcessEngineConfiguration().getEventDispatcher();
for (ProcessDefinition processDefinition : processDefinitions) {
// Since all process definitions are deleted by a single query, we should dispatch the events in this loop
if (eventDispatcher.isEnabled()) {
eventDispatcher.dispatchEvent(ActivitiEventBuilder.createEntityEvent(
FlowableEngineEventType.ENTITY_DELETED, processDefinition),
EngineConfigurationConstants.KEY_PROCESS_ENGINE_CONFIG);
}
}View on GitHub (pinned to d6d39ce1c6)