{"record":{"id":"0dd6179ef056fd5f","repo":"flowable/flowable-engine","slug":"inputstream-for-resource-resourcename-is-null-0dd617","errorCode":null,"errorMessage":"inputStream for resource '${resourceName}' is null","messagePattern":"inputStream for resource '(.+?)' is null","errorType":"validation","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/repository/CmmnDeploymentBuilderImpl.java","lineNumber":52,"sourceCode":"\n    protected transient CmmnRepositoryServiceImpl repositoryService;\n    protected transient CmmnResourceEntityManager resourceEntityManager;\n\n    protected CmmnDeploymentEntity deployment;\n    protected boolean isCmmn20XsdValidationEnabled = true;\n    protected boolean isDuplicateFilterEnabled;\n\n    public CmmnDeploymentBuilderImpl() {\n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration();\n        this.repositoryService = (CmmnRepositoryServiceImpl) cmmnEngineConfiguration.getCmmnRepositoryService();\n        this.deployment = cmmnEngineConfiguration.getCmmnDeploymentEntityManager().create();\n        this.resourceEntityManager = cmmnEngineConfiguration.getCmmnResourceEntityManager();\n    }\n\n    @Override\n    public CmmnDeploymentBuilder 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        CmmnResourceEntity resource = resourceEntityManager.create();\n        resource.setName(resourceName);\n        resource.setBytes(bytes);\n        deployment.addResource(resource);\n        return this;","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/repository/CmmnDeploymentBuilderImpl.java#L34-L70","documentation":"CmmnDeploymentBuilderImpl.addInputStream throws FlowableException with \"inputStream for resource '<resourceName>' is null\" when a null InputStream is registered as a deployment resource. The builder reads the whole stream into bytes immediately, so a null stream cannot be processed and deployment must abort.","triggerScenarios":"Calling addInputStream(name, null) directly, or indirectly via addClasspathResource when the classpath resource does not exist (getResourceAsStream returns null).","commonSituations":"Typo in the classpath resource path; resource not included in the build/jar; file was moved or renamed; loading from a wrong classloader (e.g. different WAR/module).","solutions":["Verify the resource name/path is correct and that the file exists on the classpath before adding it.","Check that the InputStream-producing code (e.g. getClass().getResourceAsStream) is null-checked and that the stream is not closed/never opened.","If reading from a file, prefer repositoryService createDeployment().addClasspathResource(...) with a verified path or addInputStream over a FileInputStream you confirmed exists."],"exampleFix":"// before\nInputStream is = getClass().getResourceAsStream(resourcePath);\nbuilder.addInputStream(resourcePath, is); // NPE-safe but throws here\n\n// after\nInputStream is = getClass().getResourceAsStream(resourcePath);\nif (is == null) {\n    throw new IllegalStateException(\"resource not on classpath: \" + resourcePath);\n}\nbuilder.addInputStream(resourcePath, is);","handlingStrategy":"validation","validationCode":"InputStream is = getClass().getResourceAsStream(path);\nif (is == null) {\n    throw new IllegalStateException(\"resource missing on classpath: \" + path);\n}\nbuilder.addInputStream(path, is);","typeGuard":"boolean resourceExists(String path) {\n    return getClass().getResource(path) != null;\n}","tryCatchPattern":"try {\n    builder.addInputStream(name, is);\n} catch (FlowableException e) {\n    if (!e.getMessage().contains(\"is null\")) throw e;\n    throw new DeploymentException(\"resource stream missing: \" + name, e);\n}","preventionTips":["Check getResourceAsStream return value before use","Verify resource files are included in the build artifacts","Use addClasspathResource with verified paths in tests"],"tags":["null-argument","deployment","cmmn","resource-not-found"],"backgroundTag":"resource-not-found","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"}