{"record":{"id":"15f295589fb8d3e5","repo":"flowable/flowable-engine","slug":"failed-to-read-resource-resource-15f295","errorCode":null,"errorMessage":"Failed to read resource ${resource}","messagePattern":"Failed to read resource (.+?)","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/repository/DmnDeploymentBuilderImpl.java","lineNumber":87,"sourceCode":"        }\n\n        DmnResourceEntity resource = resourceEntityManager.create();\n        resource.setName(resourceName);\n        resource.setBytes(bytes);\n        deployment.addResource(resource);\n        return this;\n    }\n\n    @Override\n    public DmnDeploymentBuilder addClasspathResource(String resource) {\n        try (final InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(resource)) {\n            if (inputStream == null) {\n                throw new FlowableException(\"resource '\" + resource + \"' not found\");\n            }\n            return addInputStream(resource, inputStream);\n            \n        } catch (IOException ex) {\n            throw new FlowableException(\"Failed to read resource \" + resource, ex);\n        }\n    }\n\n    @Override\n    public DmnDeploymentBuilder addString(String resourceName, String text) {\n        if (text == null) {\n            throw new FlowableException(\"text is null\");\n        }\n\n        DmnResourceEntity 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 DmnDeploymentBuilder addDmnBytes(String resourceName, byte[] dmnBytes) {","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/repository/DmnDeploymentBuilderImpl.java#L69-L105","documentation":"DmnDeploymentBuilderImpl.addClasspathResource wraps its classloader read in try-with-resources; if closing/reading the stream raises IOException, it rethrows as FlowableException('Failed to read resource ' + resource, ex). Unlike the null-stream case, the resource WAS found but the underlying stream could not be read successfully.","triggerScenarios":"Calling addClasspathResource where getResourceAsStream returns a valid stream but reading or closing it throws IOException — e.g. the resource is backed by a defective jar entry, a corrupt classpath jar, an interrupted/closed underlying stream, or a custom classloader whose stream fails on read.","commonSituations":"Corrupted jars in the application server's lib directory, partially-built artifacts, custom classloading setups in application servers (WebSphere/WebLogic) that return failing streams, or file-system issues with exploded classpath directories (permissions, NFS mount dropouts).","solutions":["Inspect the wrapped IOException cause (ex.getCause()) to find the real read failure and fix the underlying stream/jar problem.","Rebuild and redeploy the artifact — a corrupted or partially written jar entry is the most common root cause.","Test reading the resource directly (getClass().getClassLoader().getResourceAsStream(resource).read()) to reproduce outside the deployment builder.","If a custom classloader or app-server classloading delegation is involved, add the resource to a parent/visible classpath location."],"exampleFix":"// before\ntry {\n    dmnRepositoryService.createDeployment().addClasspathResource(\"dmn/decision.dmn\").deploy();\n} catch (FlowableException e) {\n    log.error(e.getMessage()); // swallows the root cause\n}\n// after\ntry {\n    dmnRepositoryService.createDeployment().addClasspathResource(\"dmn/decision.dmn\").deploy();\n} catch (FlowableException e) {\n    log.error(\"DMN deployment failed\", e); // inspect the IOException cause\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    dmnRepositoryService.createDeployment().addClasspathResource(resource).deploy();\n} catch (FlowableException e) {\n    if (e.getCause() instanceof IOException) {\n        throw new DeploymentIoException(\"Could not read DMN resource \" + resource + \": \" + e.getCause().getMessage(), e);\n    }\n    throw e;\n}","preventionTips":["Log the full exception chain (getCause) to identify the underlying I/O failure.","Validate jar integrity after builds; rebuild on suspicious partial artifacts.","Be cautious with custom classloaders / app-server classloader delegation when loading resources."],"tags":["java","flowable","io","resource-read","deployment"],"backgroundTag":"file-read-failed","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"}