{"record":{"id":"5a0bdceb608752ff","repo":"flowable/flowable-engine","slug":"inputstream-for-resource-resourcename-is-null-5a0bdc","errorCode":null,"errorMessage":"inputStream for resource '${resourceName}' is null","messagePattern":"inputStream for resource '(.+?)' is null","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":57,"sourceCode":"\n    protected transient DmnRepositoryServiceImpl repositoryService;\n    protected transient DmnResourceEntityManager resourceEntityManager;\n\n    protected DmnDeploymentEntity deployment;\n    protected boolean isDmn20XsdValidationEnabled = true;\n    protected boolean isDuplicateFilterEnabled;\n\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;","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/repository/DmnDeploymentBuilderImpl.java#L39-L75","documentation":"DmnDeploymentBuilderImpl.addInputStream requires a non-null InputStream to build the DMN deployment resource. Passing null means no bytes can be stored for the named resource, so Flowable fails fast with a FlowableException. This is a caller-side argument error, not a deployment failure.","triggerScenarios":"Calling dmnRepositoryService.createDeployment().addInputStream(name, is) with a null stream — typically when a prior getResourceAsStream(name) on the classpath returned null, or a variable holding the stream was never initialized. addClasspathResource delegates to addInputStream, so a classpath resource that does not exist surfaces here too.","commonSituations":"Typo in the .dmn XML resource path inside src/main/resources; resource not copied into the artifact (missing Maven resource include); reading from a closed/failed loader that returned null instead of throwing; CI packaging excludes the resource directory.","solutions":["Verify the resource actually exists on the classpath: try (InputStream is = getClass().getResourceAsStream(path)) { assert is != null; } and fix the path (leading slash, package directory) if null.","Check your build config (Maven <resources> / Gradle processResources) includes *.dmn files so they land in the jar.","Null-check or use Objects.requireNonNull(inputStream) before calling addInputStream to get a clearer stack trace at your call site.","Use addClasspathResource with a corrected classpath location, or read via Files.newInputStream(Paths.get(file)) for filesystem resources."],"exampleFix":"// before\nInputStream is = getClass().getResourceAsStream(\"decision.dmn\"); // null: wrong path\nbuilder.addInputStream(\"decision.dmn\", is);\n\n// after\nString path = \"/diagrams/decision.dmn\";\nInputStream is = getClass().getResourceAsStream(path);\nif (is == null) throw new IllegalStateException(\"Resource not on classpath: \" + path);\nbuilder.addInputStream(\"decision.dmn\", is);","handlingStrategy":"type-guard","validationCode":"String path = \"/diagrams/decision.dmn\";\ntry (InputStream is = getClass().getResourceAsStream(path)) {\n    if (is == null) throw new IllegalArgumentException(\"DMN resource missing from classpath: \" + path);\n}","typeGuard":"function hasResource(String path) {\n    try (InputStream is = getClass().getResourceAsStream(path)) {\n        return is != null;\n    } catch (IOException e) { return false; }\n}","tryCatchPattern":"try {\n    builder.addInputStream(name, inputStream);\n} catch (FlowableException e) {\n    if (e.getMessage().startsWith(\"inputStream for resource\")) {\n        // stream was null: re-open resource or fail deployment with clear message\n    } else { throw e; }\n}","preventionTips":["Null-check getResourceAsStream results before passing them on.","Verify build config copies *.dmn resources into the artifact.","Prefer addClasspathResource over manual stream handling.","Fail fast at load time with Objects.requireNonNull(stream)."],"tags":["flowable","dmn","deployment","null-argument"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}