{"record":{"id":"d747536b1a43b562","repo":"flowable/flowable-engine","slug":"failed-to-read-resource-resource-d74753","errorCode":null,"errorMessage":"Failed to read resource ${resource}","messagePattern":"Failed to read resource (.+?)","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/repository/EventDeploymentBuilderImpl.java","lineNumber":84,"sourceCode":"        }\n\n        EventResourceEntity resource = resourceEntityManager.create();\n        resource.setName(resourceName);\n        resource.setBytes(bytes);\n        deployment.addResource(resource);\n        return this;\n    }\n\n    @Override\n    public EventDeploymentBuilder 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 EventDeploymentBuilder addString(String resourceName, String text) {\n        if (text == null) {\n            throw new FlowableException(\"text is null\");\n        }\n\n        EventResourceEntity 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 EventDeploymentBuilder addEventDefinitionBytes(String resourceName, byte[] eventDefinitionBytes) {","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/repository/EventDeploymentBuilderImpl.java#L66-L102","documentation":"FlowableException thrown by EventDeploymentBuilderImpl.addClasspathResource when reading a classpath resource fails with an IOException (or the resource stream cannot be processed) during deployment resource loading. The builder loads classpath resources as event/channel definition files into the deployment. The causing IOException is attached as the cause.","triggerScenarios":"Calling EventDeploymentBuilder.addClasspathResource(resource) where the resource exists but reading its InputStream throws IOException (e.g. stream already consumed, broken classloader/JAR).","commonSituations":"Deploying event definitions from a JAR with a corrupted or closed stream; resources inside an executable JAR accessed via FileInputStream-style assumptions; classloader quirks in app servers.","solutions":["Verify the classpath resource exists via getClass().getResourceAsStream(resource) before calling addClasspathResource.","Check that the underlying file/JAR is readable and not corrupted.","Inspect the wrapped IOException cause for the actual read failure.","If the resource is missing, note the distinct 'resource not found' FlowableException path and fix the resource path/name."],"exampleFix":"// before\ndeploymentBuilder.addClasspathResource(\"events/order.event\");\n// after\ntry (InputStream is = getClass().getClassLoader().getResourceAsStream(\"events/order.event\")) {\n    if (is != null) {\n        deploymentBuilder.addInputStream(\"events/order.event\", is);\n    }\n}","handlingStrategy":"try-catch","validationCode":"if (getClass().getClassLoader().getResource(resource) == null) { throw new IllegalArgumentException(\"classpath resource missing: \" + resource); }","typeGuard":"boolean exists = getClass().getClassLoader().getResource(resource) != null;","tryCatchPattern":"try { builder.addClasspathResource(resource); } catch (FlowableException e) { LOG.error(\"failed reading deployment resource \" + resource, e.getCause()); throw e; }","preventionTips":["Check resource existence with getResource before deploying","Keep definition files on the runtime classpath of the deploying app","Log the wrapped IOException cause to distinguish missing vs unreadable resources"],"tags":["flowable","deployment","io","classpath-resource"],"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-18T16:30:33.424Z"}