{"record":{"id":"b89039076dd3d56b","repo":"flowable/flowable-engine","slug":"inputstream-for-resource-is-null","errorCode":null,"errorMessage":"inputStream for resource '' is null","messagePattern":"inputStream for resource '' is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/repository/DeploymentBuilderImpl.java","lineNumber":66,"sourceCode":"    protected transient ResourceEntityManager resourceEntityManager;\n\n    protected DeploymentEntity deployment;\n    protected boolean isBpmn20XsdValidationEnabled = true;\n    protected boolean isProcessValidationEnabled = true;\n    protected boolean isDuplicateFilterEnabled;\n    protected Date processDefinitionsActivationDate;\n    protected Map<String, Object> deploymentProperties = new HashMap<>();\n\n    public DeploymentBuilderImpl(RepositoryServiceImpl repositoryService) {\n        this.repositoryService = repositoryService;\n        this.deployment = CommandContextUtil.getProcessEngineConfiguration().getDeploymentEntityManager().create();\n        this.resourceEntityManager = CommandContextUtil.getProcessEngineConfiguration().getResourceEntityManager();\n    }\n\n    @Override\n    public DeploymentBuilder addInputStream(String resourceName, InputStream inputStream) {\n        if (inputStream == null) {\n            throw new FlowableIllegalArgumentException(\"inputStream for resource '\" + resourceName + \"' is null\");\n        }\n        byte[] bytes = IoUtil.readInputStream(inputStream, resourceName);\n        ResourceEntity resource = resourceEntityManager.create();\n        resource.setName(resourceName);\n        resource.setBytes(bytes);\n        deployment.addResource(resource);\n        return this;\n    }\n\n    @Override\n    public DeploymentBuilder addClasspathResource(String resource) {\n        try (final InputStream inputStream = ReflectUtil.getResourceAsStream(resource)) {\n\t        if (inputStream == null) {\n\t            throw new FlowableIllegalArgumentException(\"resource '\" + resource + \"' not found\");\n\t        }\n\t        return addInputStream(resource, inputStream);\n\t        \n        } catch (IOException ex) {","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/repository/DeploymentBuilderImpl.java#L48-L84","documentation":"DeploymentBuilderImpl.addInputStream validates that the given InputStream is non-null before reading it. A null stream cannot be converted into a deployment resource, so a FlowableIllegalArgumentException naming the resource is thrown immediately.","triggerScenarios":"Calling repositoryService.createDeployment().addInputStream(name, stream) with a stream variable that is null — e.g. getResourceAsStream/ClassLoader lookup returned null, an IO helper produced null, or the stream variable was never initialized.","commonSituations":"Loading BPMN/XML from a classpath or file path that doesn't exist so the loader returns null instead of throwing; refactoring that renamed a resource leaving the stream null; dynamic resource resolution in CI tooling passing null on missing files.","solutions":["Ensure the InputStream is produced successfully (check the classpath resource exists) before calling addInputStream.","If the resource may be absent, check for null first and fail with your own descriptive error.","Prefer addClasspathResource(String) which loads and validates the resource in one call.","Close streams properly (try-with-resources) so failed reads don't leave null/partial streams."],"exampleFix":"// before\nrepositoryService.createDeployment().addInputStream(\"process.bpmn20.xml\", getClass().getResourceAsStream(path)).deploy();\n// after\ntry (InputStream is = getClass().getResourceAsStream(path)) {\n    if (is == null) throw new IllegalArgumentException(\"Missing resource: \" + path);\n    repositoryService.createDeployment().addInputStream(\"process.bpmn20.xml\", is).deploy();\n}","handlingStrategy":"type-guard","validationCode":"InputStream is = getClass().getResourceAsStream(path);\nif (is == null) throw new IllegalArgumentException(\"Resource missing on classpath: \" + path);","typeGuard":"boolean hasStream(InputStream is) { return is != null; }","tryCatchPattern":"try { builder.addInputStream(name, is); } catch (FlowableIllegalArgumentException e) { if (e.getMessage().startsWith(\"inputStream for resource\")) { /* fix resource loading */ } else throw e; }","preventionTips":["Never pass the raw result of getResourceAsStream without a null check","Prefer addClasspathResource for classpath entries","Close streams with try-with-resources"],"tags":["deployment","null-argument","repository"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}