{"record":{"id":"9940c5c7ec6abe9f","repo":"Activiti/Activiti","slug":"no-deployment-found-for-id-deploymentid","errorCode":null,"errorMessage":"No deployment found for id = '${deploymentId}'","messagePattern":"No deployment found for id = '(.+?)'","errorType":"exception","errorClass":"ActivitiObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/SetDeploymentCategoryCmd.java","lineNumber":48,"sourceCode":"public class SetDeploymentCategoryCmd implements Command<Void> {\n\n    protected String deploymentId;\n    protected String category;\n\n    public SetDeploymentCategoryCmd(String deploymentId, String category) {\n        this.deploymentId = deploymentId;\n        this.category = category;\n    }\n\n    public Void execute(CommandContext commandContext) {\n        if (deploymentId == null) {\n            throw new ActivitiIllegalArgumentException(\"Deployment id is null\");\n        }\n\n        DeploymentEntity deployment = commandContext.getDeploymentEntityManager().findById(deploymentId);\n\n        if (deployment == null) {\n            throw new ActivitiObjectNotFoundException(\n                \"No deployment found for 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        // Update category\n        deployment.setCategory(category);\n\n        if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {\n            commandContext\n                .getProcessEngineConfiguration()\n                .getEventDispatcher()\n                .dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, deployment));","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/Activiti/Activiti/blob/56435b1a97deeafdc09dd40074b056c89fba5a8a/activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/SetDeploymentCategoryCmd.java#L30-L66","documentation":"After validating the id is non-null, SetDeploymentCategoryCmd looks up the deployment via DeploymentEntityManager.findById. If no deployment row exists for the given id, Activiti throws ActivitiObjectNotFoundException with the message 'No deployment found for id = ...'.","triggerScenarios":"Calling RepositoryService.setDeploymentCategory(id, category) with an id that does not exist in ACT_RE_DEPLOYMENT (deleted deployment, typo, id from another database/environment).","commonSituations":"Referencing a deployment deleted by deleteDeployment, pointing a test at a different DB schema, stale cached ids after a re-deployment, or copying ids across environments.","solutions":["Verify the deploymentId exists: repositoryService.createDeploymentQuery().deploymentId(id).singleResult() != null before calling setDeploymentCategory.","List valid ids with createDeploymentQuery().list() and use one of those.","Confirm the engine is connected to the database/environment where the deployment was made."],"exampleFix":"// before\nrepositoryService.setDeploymentCategory(deploymentId, \"production\");\n// after\nDeployment d = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();\nif (d != null) {\n  repositoryService.setDeploymentCategory(deploymentId, \"production\");\n}","handlingStrategy":"validation","validationCode":"Deployment d = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();\nif (d == null) {\n  throw new IllegalStateException(\"Deployment \" + deploymentId + \" does not exist\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  repositoryService.setDeploymentCategory(deploymentId, category);\n} catch (ActivitiObjectNotFoundException e) {\n  if (Deployment.class.equals(e.getObjectClass())) {\n    // fall back: list valid deployments or notify caller the id is stale\n  } else { throw e; }\n}","preventionTips":["Query the deployment before mutating it.","Never reuse ids across environments or after deleteDeployment.","Prefer key/category-based queries over stored raw ids when possible."],"tags":["activiti","not-found","deployment"],"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"}