flowable/flowable-engine · error · ActivitiObjectNotFoundException
deployment does not exist:
Error message
deployment does not exist:
What it means
When no resource is found for the (deploymentId, resourceName) pair, the command checks whether the deployment itself exists. If it does not, it throws ActivitiObjectNotFoundException("deployment does not exist: " + deploymentId, Deployment.class). This distinguishes a missing deployment from a missing resource within an existing deployment.
Solutions
- Deploy first and use the returned deployment id instead of a hard-coded one.
- Verify with repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult() before fetching resources.
- Look up the latest deployment by key/name: createDeploymentQuery().orderByDeploymentTime().desc().listPage(0,1).
Example fix
// before
InputStream is = repositoryService.getResourceAsStream(deploymentId, "process.bpmn20.xml"); // ObjectNotFound if deployment gone
// after
Deployment dep = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
if (dep == null) {
dep = repositoryService.createDeployment().addClasspathResource("process.bpmn20.xml").deploy();
deploymentId = dep.getId();
}
InputStream is = repositoryService.getResourceAsStream(deploymentId, "process.bpmn20.xml"); Defensive patterns
Strategy: try-catch
Validate before calling
Deployment dep = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
if (dep == null) {
throw new IllegalStateException("Deployment " + deploymentId + " does not exist");
} Try / catch
try {
return repositoryService.getResourceAsStream(deploymentId, resourceName);
} catch (ActivitiObjectNotFoundException e) {
if (Deployment.class.getName().equals(String.valueOf(e.getObjectType()))) {
redeploy();
return repositoryService.getResourceAsStream(deploymentId, resourceName);
}
throw e;
} Prevention
- Re-resolve the latest deployment instead of persisting deployment ids in config files.
- Account for environment resets (in-memory H2 databases) that wipe deployments.
When it happens
Trigger: repositoryService.getResourceAsStream(deploymentId, resourceName) where deploymentId refers to a deployment that was never created or has been deleted.
Common situations: Hard-coded deployment ids after redeployments (id changes each deploy); database cleaned/re-created between environments; cascade-delete removed the deployment while cached ids were still used.
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 resource with id
- deployment does not exist
- deployment does not exist
- Form with formKey ' ' does not exist
- inputStream for resource
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/456491675dcdeda1.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetDeploymentResourceCmd.java:54
this.deploymentId = deploymentId;
this.resourceName = resourceName;
}
@Override
public InputStream execute(CommandContext commandContext) {
if (deploymentId == null) {
throw new ActivitiIllegalArgumentException("deploymentId is null");
}
if (resourceName == null) {
throw new ActivitiIllegalArgumentException("resourceName is null");
}
ResourceEntity resource = commandContext
.getResourceEntityManager()
.findResourceByDeploymentIdAndResourceName(deploymentId, resourceName);
if (resource == null) {
if (commandContext.getDeploymentEntityManager().findDeploymentById(deploymentId) == null) {
throw new ActivitiObjectNotFoundException("deployment does not exist: " + deploymentId, Deployment.class);
} else {
throw new ActivitiObjectNotFoundException("no resource found with name '" + resourceName + "' in deployment '" + deploymentId + "'", InputStream.class);
}
}
return new ByteArrayInputStream(resource.getBytes());
}
}
View on GitHub (pinned to d6d39ce1c6)