{"record":{"id":"3766fd3d220ae899","repo":"Activiti/Activiti","slug":"could-not-find-deployment-with-id-deploymentid","errorCode":null,"errorMessage":"Could not find deployment with id ${deploymentId}","messagePattern":"Could not find deployment with id (.+?)","errorType":"exception","errorClass":"ActivitiObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/ChangeDeploymentTenantIdCmd.java","lineNumber":53,"sourceCode":"\n    protected String deploymentId;\n    protected String newTenantId;\n\n    public ChangeDeploymentTenantIdCmd(String deploymentId, String newTenantId) {\n        this.deploymentId = deploymentId;\n        this.newTenantId = newTenantId;\n    }\n\n    public Void execute(CommandContext commandContext) {\n        if (deploymentId == null) {\n            throw new ActivitiIllegalArgumentException(\"deploymentId is null\");\n        }\n\n        // Update all entities\n\n        DeploymentEntity deployment = commandContext.getDeploymentEntityManager().findById(deploymentId);\n        if (deployment == null) {\n            throw new ActivitiObjectNotFoundException(\n                \"Could not find deployment with id \" + deploymentId,\n                Deployment.class\n            );\n        }\n\n        executeInternal(commandContext, deployment);\n        return null;\n    }\n\n    protected void executeInternal(CommandContext commandContext, DeploymentEntity deployment) {\n        String oldTenantId = deployment.getTenantId();\n        deployment.setTenantId(newTenantId);\n\n        // Doing process instances, executions and tasks with direct SQL updates\n        // (otherwise would not be performant)\n        commandContext\n            .getProcessDefinitionEntityManager()\n            .updateProcessDefinitionTenantIdForDeployment(deploymentId, newTenantId);","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/Activiti/Activiti/blob/56435b1a97deeafdc09dd40074b056c89fba5a8a/activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/ChangeDeploymentTenantIdCmd.java#L35-L71","documentation":"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.","triggerScenarios":"Calling repositoryService.changeDeploymentTenantId(deploymentId, newTenantId) with an id that does not exist — typo, deleted deployment, or wrong database.","commonSituations":"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.","solutions":["Verify with repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult() before changing the tenant.","Look up the deployment by name/key if the id is unknown: createDeploymentQuery().deploymentName(name).","Point the migration at the correct database where the deployment exists."],"exampleFix":"// before\nrepositoryService.changeDeploymentTenantId(\"dep-42\", \"tenant-2\");\n// after\nDeployment dep = repositoryService.createDeploymentQuery()\n    .deploymentId(\"dep-42\").singleResult();\nif (dep != null) {\n    repositoryService.changeDeploymentTenantId(\"dep-42\", \"tenant-2\");\n}","handlingStrategy":"validation","validationCode":"Deployment dep = repositoryService.createDeploymentQuery()\n    .deploymentId(deploymentId).singleResult();\nif (dep == null) {\n    throw new IllegalStateException(\"Deployment not found: \" + deploymentId);\n}","typeGuard":"boolean deploymentExists(RepositoryService rs, String id) {\n    return id != null && rs.createDeploymentQuery().deploymentId(id).count() > 0;\n}","tryCatchPattern":"try {\n    repositoryService.changeDeploymentTenantId(deploymentId, newTenantId);\n} catch (ActivitiObjectNotFoundException e) {\n    log.error(\"Deployment {} not found\", deploymentId, e);\n}","preventionTips":["Verify deployment existence before tenant migrations","Keep id references in sync with redeployments and cleanup jobs","Run migrations against the correct schema/database"],"tags":["java","activiti","not-found","deployment","tenant"],"backgroundTag":"resource-not-found","analyzedSha":"56435b1a97deeafdc09dd40074b056c89fba5a8a","analyzedAt":"2026-09-09T21:00:06.703Z","contentChangedAt":"2026-09-09T21:00:06.703Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}