{"record":{"id":"9a0e09bf644d09da","repo":"flowable/flowable-engine","slug":"could-not-get-byte-array-from-resource-resource-9a0e09","errorCode":null,"errorMessage":"could not get byte array from resource '${resourceName}'","messagePattern":"could not get byte array from 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":64,"sourceCode":"\n    public DmnDeploymentBuilderImpl() {\n        DmnEngineConfiguration dmnEngineConfiguration = CommandContextUtil.getDmnEngineConfiguration();\n        this.repositoryService = (DmnRepositoryServiceImpl) dmnEngineConfiguration.getDmnRepositoryService();\n        this.deployment = dmnEngineConfiguration.getDeploymentEntityManager().create();\n        this.resourceEntityManager = dmnEngineConfiguration.getResourceEntityManager();\n    }\n\n    @Override\n    public DmnDeploymentBuilder addInputStream(String resourceName, InputStream inputStream) {\n        if (inputStream == null) {\n            throw new FlowableException(\"inputStream for resource '\" + resourceName + \"' is null\");\n        }\n\n        byte[] bytes = null;\n        try {\n            bytes = IOUtils.toByteArray(inputStream);\n        } catch (Exception e) {\n            throw new FlowableException(\"could not get byte array from resource '\" + resourceName + \"'\", e);\n        }\n\n        if (bytes == null) {\n            throw new FlowableException(\"byte array for resource '\" + resourceName + \"' is null\");\n        }\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\");","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/repository/DmnDeploymentBuilderImpl.java#L46-L82","documentation":"While reading the given resource's InputStream into a byte array with IOUtils.toByteArray, an exception occurred, so DmnDeploymentBuilderImpl.addInputStream wraps it in a FlowableException with this message and the original cause attached. The stream could not be fully read, meaning the resource bytes are unavailable for the deployment.","triggerScenarios":"Calling addInputStream(name, is) where the stream throws during read — closed stream (e.g. read once then reused), network/URL stream interrupted, IO errors on an underlying file, or a stream implementation that fails mid-read. addClasspathResource passes through here on such failures.","commonSituations":"Reusing an already-consumed/closed InputStream from another engine call; reading a resource from an unstable network location; disk or permission problems on the source file; interrupted downloads streamed directly into the deployment builder.","solutions":["Inspect the wrapped cause (e.getCause()) to see the underlying IOException and fix the source (permissions, network, path).","Always pass a fresh, open InputStream — never a stream that was already read or closed; re-create it from the source before each deploy.","For classpath resources use addClasspathResource(name) so the builder opens the stream itself.","If reading from a file, verify it exists and is readable first, or buffer it fully into byte[] yourself and pass a ByteArrayInputStream."],"exampleFix":"// before: stream already consumed/closed\nInputStream is = getClass().getResourceAsStream(\"decision.dmn\");\nis.read(); // consumed elsewhere\nbuilder.addInputStream(\"decision.dmn\", is); // throws here\n\n// after: fresh stream per deployment\nbuilder.addClasspathResource(\"decision.dmn\");","handlingStrategy":"try-catch","validationCode":"try (InputStream is = Files.newInputStream(path)) {\n    is.readAllBytes(); // pre-validate the resource is fully readable\n}","typeGuard":null,"tryCatchPattern":"try {\n    builder.addInputStream(name, is);\n} catch (FlowableException e) {\n    if (e.getMessage().startsWith(\"could not get byte array\")) {\n        Throwable cause = e.getCause(); // inspect underlying IOException\n        // re-open a fresh stream and retry once\n    } else { throw e; }\n}","preventionTips":["Never reuse or pre-consume an InputStream; open a fresh one per deployment.","Prefer addClasspathResource so Flowable manages stream lifecycle.","Check file permissions and disk health for file-based sources.","Log e.getCause() to diagnose the real IO problem."],"tags":["flowable","dmn","deployment","io"],"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-18T11:17:12.947Z"}