{"record":{"id":"e897ac9b11918d20","repo":"flowable/flowable-engine","slug":"could-not-get-byte-array-from-resource-resource","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-app-engine/src/main/java/org/flowable/app/engine/impl/repository/AppDeploymentBuilderImpl.java","lineNumber":58,"sourceCode":"\n    public AppDeploymentBuilderImpl() {\n        AppEngineConfiguration appEngineConfiguration = CommandContextUtil.getAppEngineConfiguration();\n        this.repositoryService = (AppRepositoryServiceImpl) appEngineConfiguration.getAppRepositoryService();\n        this.deployment = appEngineConfiguration.getAppDeploymentEntityManager().create();\n        this.resourceEntityManager = appEngineConfiguration.getAppResourceEntityManager();\n    }\n\n    @Override\n    public AppDeploymentBuilder 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 = IoUtil.readInputStream(inputStream, resourceName);\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        AppResourceEntity resource = resourceEntityManager.create();\n        resource.setName(resourceName);\n        resource.setBytes(bytes);\n        deployment.addResource(resource);\n        return this;\n    }\n\n    @Override\n    public AppDeploymentBuilder 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":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-app-engine/src/main/java/org/flowable/app/engine/impl/repository/AppDeploymentBuilderImpl.java#L40-L76","documentation":"While reading the provided InputStream into a byte array with IoUtil.readInputStream, an exception occurred; addInputStream() wraps it and rethrows FlowableException('could not get byte array from resource ...') with the original exception as cause. The cause (I/O error, closed stream) is the real diagnostic.","triggerScenarios":"Calling addInputStream (directly or via addClasspathResource) with a stream whose backing source is broken or already closed — e.g. a closed FileInputStream, a socket stream that errored, or a stream consumed by a previous read.","commonSituations":"Reusing an InputStream that was already read; streams from files that were deleted or locked mid-read; interrupted/failed I/O when loading from a network or archive source.","solutions":["Inspect the wrapped cause (e.getCause()) for the real I/O problem and fix it.","Open a fresh InputStream for each deployment; never reuse an already-consumed stream.","Ensure the backing file/resource is readable and not deleted/locked at deploy time.","Wrap stream creation and deployment in try-with-resources so streams are open and valid during the read."],"exampleFix":"// before\nInputStream in = oldCache.get(resourceName); // already-consumed stream\ndeploymentBuilder.addInputStream(resourceName, in); // read fails\n\n// after\ntry (InputStream in = getClass().getClassLoader().getResourceAsStream(resourceName)) {\n    deploymentBuilder.addInputStream(resourceName, in);\n}","handlingStrategy":"try-catch","validationCode":"if (!Files.isReadable(Paths.get(filePath))) { throw new IllegalStateException(\"Resource not readable: \" + filePath); }","typeGuard":null,"tryCatchPattern":"try { deploymentBuilder.addInputStream(name, in); } catch (FlowableException e) { log.error(\"Failed reading resource {} : {}\", name, e.getCause(), e); }","preventionTips":["Always log e.getCause() — the wrapped IOException carries the real diagnosis.","Never reuse an already-consumed InputStream; open a new one per deployment.","Check file readability/existence before building the stream."],"tags":["flowable","deployment","io-error"],"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"}