{"record":{"id":"456491675dcdeda1","repo":"flowable/flowable-engine","slug":"deployment-does-not-exist-456491","errorCode":null,"errorMessage":"deployment does not exist: ","messagePattern":"deployment does not exist: ","errorType":"exception","errorClass":"ActivitiObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetDeploymentResourceCmd.java","lineNumber":54,"sourceCode":"        this.deploymentId = deploymentId;\n        this.resourceName = resourceName;\n    }\n\n    @Override\n    public InputStream execute(CommandContext commandContext) {\n        if (deploymentId == null) {\n            throw new ActivitiIllegalArgumentException(\"deploymentId is null\");\n        }\n        if (resourceName == null) {\n            throw new ActivitiIllegalArgumentException(\"resourceName is null\");\n        }\n\n        ResourceEntity resource = commandContext\n                .getResourceEntityManager()\n                .findResourceByDeploymentIdAndResourceName(deploymentId, resourceName);\n        if (resource == null) {\n            if (commandContext.getDeploymentEntityManager().findDeploymentById(deploymentId) == null) {\n                throw new ActivitiObjectNotFoundException(\"deployment does not exist: \" + deploymentId, Deployment.class);\n            } else {\n                throw new ActivitiObjectNotFoundException(\"no resource found with name '\" + resourceName + \"' in deployment '\" + deploymentId + \"'\", InputStream.class);\n            }\n        }\n        return new ByteArrayInputStream(resource.getBytes());\n    }\n\n}\n","sourceCodeStart":36,"sourceCodeEnd":63,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetDeploymentResourceCmd.java#L36-L63","documentation":"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.","triggerScenarios":"repositoryService.getResourceAsStream(deploymentId, resourceName) where deploymentId refers to a deployment that was never created or has been deleted.","commonSituations":"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.","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)."],"exampleFix":"// before\nInputStream is = repositoryService.getResourceAsStream(deploymentId, \"process.bpmn20.xml\"); // ObjectNotFound if deployment gone\n// after\nDeployment dep = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();\nif (dep == null) {\n    dep = repositoryService.createDeployment().addClasspathResource(\"process.bpmn20.xml\").deploy();\n    deploymentId = dep.getId();\n}\nInputStream is = repositoryService.getResourceAsStream(deploymentId, \"process.bpmn20.xml\");","handlingStrategy":"try-catch","validationCode":"Deployment dep = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();\nif (dep == null) {\n    throw new IllegalStateException(\"Deployment \" + deploymentId + \" does not exist\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return repositoryService.getResourceAsStream(deploymentId, resourceName);\n} catch (ActivitiObjectNotFoundException e) {\n    if (Deployment.class.getName().equals(String.valueOf(e.getObjectType()))) {\n        redeploy();\n        return repositoryService.getResourceAsStream(deploymentId, resourceName);\n    }\n    throw e;\n}","preventionTips":["Re-resolve the latest deployment instead of persisting deployment ids in config files.","Account for environment resets (in-memory H2 databases) that wipe deployments."],"tags":["deployment","resource-not-found","object-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}