Activiti/Activiti · error · ActivitiObjectNotFoundException

Could not find deployment with id

Error message

Could not find deployment with id ${deploymentId}

What it means

Activiti throws ActivitiObjectNotFoundException when no Deployment exists for the given deploymentId in ChangeDeploymentTenantIdCmd. The id is non-null but does not match any row in ACT_RE_DEPLOYMENT. The exception references Deployment.class.

Solutions

  1. Verify with repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult() before changing the tenant.
  2. Look up the deployment by name/key if the id is unknown: createDeploymentQuery().deploymentName(name).
  3. Point the migration at the correct database where the deployment exists.

Example fix

// before
repositoryService.changeDeploymentTenantId("dep-42", "tenant-2");
// after
Deployment dep = repositoryService.createDeploymentQuery()
    .deploymentId("dep-42").singleResult();
if (dep != null) {
    repositoryService.changeDeploymentTenantId("dep-42", "tenant-2");
}
Defensive patterns

Strategy: validation

Validate before calling

Deployment dep = repositoryService.createDeploymentQuery()
    .deploymentId(deploymentId).singleResult();
if (dep == null) {
    throw new IllegalStateException("Deployment not found: " + deploymentId);
}

Type guard

boolean deploymentExists(RepositoryService rs, String id) {
    return id != null && rs.createDeploymentQuery().deploymentId(id).count() > 0;
}

Try / catch

try {
    repositoryService.changeDeploymentTenantId(deploymentId, newTenantId);
} catch (ActivitiObjectNotFoundException e) {
    log.error("Deployment {} not found", deploymentId, e);
}

Prevention

When it happens

Trigger: Calling repositoryService.changeDeploymentTenantId(deploymentId, newTenantId) with an id that does not exist — typo, deleted deployment, or wrong database.

Common situations: Multi-tenant migrations run against the wrong schema; deployments deleted by cleanup scripts before the tenant change; ids read from stale configuration or property files.

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


AI-assisted analysis of Activiti/Activiti@56435b1a97 (2026-09-09). Data as JSON: /api/errors/3766fd3d220ae899. Report an issue: GitHub.

Appendix: source

Thrown at activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/ChangeDeploymentTenantIdCmd.java:53

    protected String deploymentId;
    protected String newTenantId;

    public ChangeDeploymentTenantIdCmd(String deploymentId, String newTenantId) {
        this.deploymentId = deploymentId;
        this.newTenantId = newTenantId;
    }

    public Void execute(CommandContext commandContext) {
        if (deploymentId == null) {
            throw new ActivitiIllegalArgumentException("deploymentId is null");
        }

        // Update all entities

        DeploymentEntity deployment = commandContext.getDeploymentEntityManager().findById(deploymentId);
        if (deployment == null) {
            throw new ActivitiObjectNotFoundException(
                "Could not find deployment with id " + deploymentId,
                Deployment.class
            );
        }

        executeInternal(commandContext, deployment);
        return null;
    }

    protected void executeInternal(CommandContext commandContext, DeploymentEntity deployment) {
        String oldTenantId = deployment.getTenantId();
        deployment.setTenantId(newTenantId);

        // Doing process instances, executions and tasks with direct SQL updates
        // (otherwise would not be performant)
        commandContext
            .getProcessDefinitionEntityManager()
            .updateProcessDefinitionTenantIdForDeployment(deploymentId, newTenantId);

View on GitHub (pinned to 56435b1a97)