{"record":{"id":"870528ab9d1876ce","repo":"flowable/flowable-engine","slug":"failed-to-read-resource","errorCode":null,"errorMessage":"Failed to read resource ","messagePattern":"Failed to read resource ","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/repository/DeploymentBuilderImpl.java","lineNumber":85,"sourceCode":"        }\n        byte[] bytes = IoUtil.readInputStream(inputStream, resourceName);\n        ResourceEntity resource = resourceEntityManager.create();\n        resource.setName(resourceName);\n        resource.setBytes(bytes);\n        deployment.addResource(resource);\n        return this;\n    }\n\n    @Override\n    public DeploymentBuilder addClasspathResource(String resource) {\n        try (final InputStream inputStream = ReflectUtil.getResourceAsStream(resource)) {\n\t        if (inputStream == null) {\n\t            throw new FlowableIllegalArgumentException(\"resource '\" + resource + \"' not found\");\n\t        }\n\t        return addInputStream(resource, inputStream);\n\t        \n        } catch (IOException ex) {\n            throw new FlowableException(\"Failed to read resource \" + resource, ex);\n        }\n\n    }\n\n    @Override\n    public DeploymentBuilder addString(String resourceName, String text) {\n        if (text == null) {\n            throw new FlowableIllegalArgumentException(\"text is null\");\n        }\n        ResourceEntity resource = resourceEntityManager.create();\n        resource.setName(resourceName);\n        resource.setBytes(text.getBytes(StandardCharsets.UTF_8));\n        deployment.addResource(resource);\n        return this;\n    }\n\n    @Override\n    public DeploymentBuilder addBytes(String resourceName, byte[] bytes) {","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/repository/DeploymentBuilderImpl.java#L67-L103","documentation":"Flowable's DeploymentBuilder.addClasspathResource loads a resource from the classpath and attaches it to a deployment as an input stream. If the classpath resource cannot be found or opened, an IOException is wrapped in a FlowableException with this message. It is the engine telling you the resource name you passed does not resolve to a readable stream.","triggerScenarios":"Calling deploymentBuilder.addClasspathResource(\"path/to/process.bpmn20.xml\") where the path does not exist on the classpath, the file name is misspelled, the resource lives in a package not on the classpath, or the stream opens but readBytesFromInputStream throws IOException while reading it.","commonSituations":"BPMN/XML/dmn resource not included in the built jar or war; resource placed under src/ instead of src/main/resources; wrong leading slash or package path; fat-jar packaging excludes non-java files; working directory differs between IDE and production so resource loading fails.","solutions":["Verify the resource exists on the classpath at the exact path passed to addClasspathResource (check target/classes or inside the built jar).","Fix the resource path: classpath resources are relative to the classpath root, so use 'org/myapp/process.bpmn20.xml', not a filesystem path.","Ensure build packaging (Maven/Gradle resources plugin) copies .bpmn/.xml/.dmn files into the artifact.","If the file may legitimately be absent, resolve it first with getClass().getClassLoader().getResource(name) and fail fast with a clear message.","If the resource exists but the stream read fails, check file permissions and that the jar/entry is not corrupted."],"exampleFix":"// before\nrepositoryService.createDeployment()\n    .addClasspathResource(\"processes/my-process.bpmn20.xml\") // FileNotFound at deploy time\n    .deploy();\n// after\nString res = \"processes/my-process.bpmn20.xml\";\nif (getClass().getClassLoader().getResource(res) == null) {\n    throw new IllegalStateException(\"Missing deployment resource: \" + res);\n}\nrepositoryService.createDeployment()\n    .addClasspathResource(res)\n    .deploy();","handlingStrategy":"validation","validationCode":"boolean resourceExists(String name) {\n    return getClass().getClassLoader().getResource(name) != null;\n}\nif (!resourceExists(\"processes/my-process.bpmn20.xml\")) throw new IllegalStateException(\"resource missing\");","typeGuard":"boolean isReadableResource(String name) {\n    if (name == null) return false;\n    try (InputStream is = getClass().getClassLoader().getResourceAsStream(name)) {\n        return is != null;\n    } catch (IOException e) { return false; }\n}","tryCatchPattern":"try {\n    repositoryService.createDeployment().addClasspathResource(name).deploy();\n} catch (FlowableException e) {\n    log.error(\"Failed to read deployment resource {}: {}\", name, e.getMessage());\n    throw new DeploymentException(name, e);\n}","preventionTips":["Keep deployment resources under src/main/resources and verify they land in target/classes or the jar.","Assert resource presence in unit tests before deployment.","Use the deployment id/URL returned by classpath resolution for diagnostics.","Enable build resource filtering/inclusion for .bpmn/.dmn/.xml files."],"tags":["java","flowable","deployment","classpath","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}