{"record":{"id":"c5889e19ce2d10bd","repo":"flowable/flowable-engine","slug":"inputstream-for-resource-resourcename-is-null-c5889e","errorCode":null,"errorMessage":"inputStream for resource '${resourceName}' is null","messagePattern":"inputStream for resource '(.+?)' is null","errorType":"validation","errorClass":"org.activiti.engine.ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/repository/DeploymentBuilderImpl.java","lineNumber":56,"sourceCode":"public class DeploymentBuilderImpl implements DeploymentBuilder, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    protected transient RepositoryServiceImpl repositoryService;\n    protected DeploymentEntity deployment = new DeploymentEntity();\n    protected boolean isBpmn20XsdValidationEnabled = true;\n    protected boolean isProcessValidationEnabled = true;\n    protected boolean isDuplicateFilterEnabled;\n    protected Date processDefinitionsActivationDate;\n\n    public DeploymentBuilderImpl(RepositoryServiceImpl repositoryService) {\n        this.repositoryService = repositoryService;\n    }\n\n    @Override\n    public DeploymentBuilder addInputStream(String resourceName, InputStream inputStream) {\n        if (inputStream == null) {\n            throw new ActivitiIllegalArgumentException(\"inputStream for resource '\" + resourceName + \"' is null\");\n        }\n        byte[] bytes = IoUtil.readInputStream(inputStream, resourceName);\n        ResourceEntity resource = new ResourceEntity();\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        InputStream inputStream = ReflectUtil.getResourceAsStream(resource);\n        if (inputStream == null) {\n            throw new ActivitiIllegalArgumentException(\"resource '\" + resource + \"' not found\");\n        }\n        return addInputStream(resource, inputStream);\n    }\n","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/repository/DeploymentBuilderImpl.java#L38-L74","documentation":"Thrown by DeploymentBuilderImpl.addInputStream when the provided InputStream argument is null. The deployment builder requires a non-null stream to read the resource bytes before adding it to the deployment. This is argument validation via ActivitiIllegalArgumentException, thrown before any deployment resource is created.","triggerScenarios":"repositoryService.createDeployment().addInputStream(name, stream) called with a null stream — e.g. getResourceAsStream returned null because the classpath resource is missing, or a failed file/network stream lookup returned null.","commonSituations":"Typo in classpath resource path so ClassLoader.getResourceAsStream returns null; loading a BPMN file from a location that doesn't exist in the packaged JAR; refactoring resource directories without updating deployment code.","solutions":["Fix the source of the stream (correct classpath path, existing file) so it isn't null","Null-check the stream and throw a clear error naming the resource before calling addInputStream","Use addClasspathResource/addString for resources so a missing file fails with a clearer message","Log/verify the resource exists in the deployed artifact (JAR/WAR)"],"exampleFix":"// before\nInputStream is = getClass().getResourceAsStream(\"proc.bpmn\");\nrepo.createDeployment().addInputStream(\"proc.bpmn\", is).deploy(); // fails if is==null\n// after\nInputStream is = getClass().getResourceAsStream(\"/processes/proc.bpmn\");\nif (is == null) throw new IllegalArgumentException(\"processes/proc.bpmn missing on classpath\");\nrepo.createDeployment().addClasspathResource(\"processes/proc.bpmn\").deploy();","handlingStrategy":"validation","validationCode":"InputStream is = getClass().getResourceAsStream(resourcePath);\nif (is == null) {\n  throw new IllegalArgumentException(\"resource not on classpath: \" + resourcePath);\n}\nrepositoryService.createDeployment().addInputStream(resourceName, is);","typeGuard":"boolean resourceExists(String p) { return getClass().getResource(p) != null; }","tryCatchPattern":"try {\n  deploymentBuilder.addInputStream(name, is).deploy();\n} catch (ActivitiIllegalArgumentException e) {\n  // stream was null — fix resource resolution\n}","preventionTips":["Prefer addClasspathResource over manual streams","Check ClassLoader.getResourceAsStream results for null","Verify resources are packaged into the deployment artifact"],"tags":["deployment","null-argument","validation"],"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"}