{"record":{"id":"3131580ef55d1e46","repo":"flowable/flowable-engine","slug":"error-converting-resource-stream","errorCode":null,"errorMessage":"Error converting resource stream","messagePattern":"Error converting resource stream","errorType":"exception","errorClass":"FlowableException","httpStatus":500,"severity":"error","filePath":"modules/flowable-app-engine-rest/src/main/java/org/flowable/app/rest/service/api/repository/AppDefinitionResourceDataResource.java","lineNumber":93,"sourceCode":"        }\n\n        // Check if deployment exists\n        AppDeployment deployment = appRepositoryService.createDeploymentQuery().deploymentId(appDefinition.getDeploymentId()).singleResult();\n        if (deployment == null) {\n            throw new FlowableObjectNotFoundException(\"Could not find a deployment with id '\" + appDefinition.getDeploymentId());\n        }\n\n        List<String> resourceList = appRepositoryService.getDeploymentResourceNames(appDefinition.getDeploymentId());\n\n        if (resourceList.contains(appDefinition.getResourceName())) {\n            final InputStream resourceStream = appRepositoryService.getResourceAsStream(\n                    appDefinition.getDeploymentId(), appDefinition.getResourceName());\n\n            response.setContentType(\"application/json\");\n            try {\n                return IOUtils.toByteArray(resourceStream);\n            } catch (Exception e) {\n                throw new FlowableException(\"Error converting resource stream\", e);\n            }\n            \n        } else {\n            // Resource not found in deployment\n            throw new FlowableObjectNotFoundException(\"Could not find a resource with id '\" +\n                    appDefinition.getResourceName() + \"' in deployment '\" + appDefinition.getDeploymentId());\n        }\n    }\n}\n","sourceCodeStart":75,"sourceCodeEnd":103,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-app-engine-rest/src/main/java/org/flowable/app/rest/service/api/repository/AppDefinitionResourceDataResource.java#L75-L103","documentation":"Thrown by AppDefinitionResourceDataResource.getAppDefinitionResource when the deployed app definition resource exists but reading its byte content from the repository resource stream fails. The library wraps the underlying IOException in a FlowableException with this message. It indicates an I/O problem while converting the resource stream to a byte array, not a missing resource.","triggerScenarios":"GET /app-repository/app-definitions/{appDefinitionId}/resource resolves the deployment resource via repositoryService.getResourceAsStream(deploymentId, resourceName), but IOUtils.toByteArray(resourceStream) throws (stream already closed, corrupted deployment store, disk/DB read failure).","commonSituations":"Database or filesystem backing the deployment store is unreachable or corrupted; resource deleted mid-request; very large resources causing OOM-wrapped read failures.","solutions":["Check the wrapped cause (e.getCause()) in server logs for the real I/O error and fix storage connectivity/corruption.","Verify the deployment is intact: redeploy the .app/ZIP artifact.","Confirm the DB/filesystem where Flowable stores deployment resources is healthy and has free space.","If OOM-related, increase heap or stream the resource instead of loading it fully into a byte array."],"exampleFix":"// before\ntry {\n    return IOUtils.toByteArray(resourceStream);\n} catch (Exception e) {\n    throw new FlowableException(\"Error converting resource stream\", e);\n}\n// after\ntry {\n    return IOUtils.toByteArray(resourceStream);\n} catch (IOException e) {\n    logger.error(\"Failed reading resource for deployment \" + appDefinition.getDeploymentId(), e);\n    throw new FlowableException(\"Error converting resource stream\", e);\n}","handlingStrategy":"try-catch","validationCode":"// Verify resource exists before fetching bytes\nAppDeploymentResourceResponse r = restTemplate.getForObject(\n  \"/app-repository/deployments/\" + deploymentId + \"/resources\", AppDeploymentResourceResponse.class);\nif (r == null) throw new IllegalStateException(\"resource missing\");","typeGuard":null,"tryCatchPattern":"try {\n    byte[] data = restTemplate.getForObject(url, byte[].class);\n} catch (HttpServerErrorException e) {\n    logger.error(\"Resource stream conversion failed; check cause on server\", e);\n    throw new IllegalStateException(\"Resource could not be read from deployment\", e);\n}","preventionTips":["Always log the root cause (getCause) on the server.","Keep deployment storage (DB/filesystem) healthy and monitored.","Redeploy artifacts if the deployment store is suspected corrupted.","Prefer streaming for large resources to avoid memory pressure."],"tags":["io","stream","flowable","rest"],"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"}