{"record":{"id":"81dc24e27a777db6","repo":"flowable/flowable-engine","slug":"invalid-multiple-sources-this-streamsource","errorCode":null,"errorMessage":"invalid: multiple sources \" + this.streamSource + \" and \" + streamSource","messagePattern":"invalid: multiple sources \" \\+ this\\.streamSource \\+ \" and \" \\+ streamSource","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/BpmnParse.java","lineNumber":264,"sourceCode":"    public BpmnParse sourceResource(String resource, ClassLoader classLoader) {\n        if (name == null) {\n            name(resource);\n        }\n        setStreamSource(new ResourceStreamSource(resource, classLoader));\n        return this;\n    }\n\n    public BpmnParse sourceString(String string) {\n        if (name == null) {\n            name(\"string\");\n        }\n        setStreamSource(new StringStreamSource(string));\n        return this;\n    }\n\n    protected void setStreamSource(StreamSource streamSource) {\n        if (this.streamSource != null) {\n            throw new FlowableIllegalArgumentException(\"invalid: multiple sources \" + this.streamSource + \" and \" + streamSource);\n        }\n        this.streamSource = streamSource;\n    }\n\n    public BpmnParse setSourceSystemId(String sourceSystemId) {\n        this.sourceSystemId = sourceSystemId;\n        return this;\n    }\n\n    /**\n     * Parses the 'definitions' root element\n     */\n    protected void applyParseHandlers() {\n        sequenceFlows = new HashMap<>();\n        for (Process process : bpmnModel.getProcesses()) {\n            currentProcess = process;\n            if (process.isExecutable()) {\n                bpmnParserHandlers.parseElement(this, process);","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/BpmnParse.java#L246-L282","documentation":"A single BpmnParse instance can only have one stream source (input stream, URL, resource, or string). setStreamSource throws FlowableIllegalArgumentException if a second source is set on a BpmnParse that already has one, since the parser would not know which content to parse.","triggerScenarios":"Reusing the same BpmnParse object and calling sourceInputStream/sourceUrl/sourceResource/sourceString twice, or chaining two source* setters on one instance.","commonSituations":"Loop that parses multiple resources but forgot to create a fresh BpmnParse per resource; copy-pasted parsing code accidentally setting source twice.","solutions":["Create a new BpmnParse per process definition (repositoryService.createDeployment() handles this per resource)","Reset or discard the BpmnParse instance before setting a new source","If you need to switch sources, build a fresh parse: processEngineConfiguration.getBpmnParseFactory().createBpmnParse(...)"],"exampleFix":"// before\nBpmnParse parse = bpmnParseFactory.createBpmnParse();\nparse.sourceResource(\"a.bpmn\").sourceResource(\"b.bpmn\").execute(); // throws\n// after\nBpmnParse parse = bpmnParseFactory.createBpmnParse();\nparse.sourceResource(\"b.bpmn\").execute();","handlingStrategy":"validation","validationCode":"if (parse.hasStreamSource()) { /* create new BpmnParse */ } // or simply always create a fresh BpmnParse per resource","typeGuard":null,"tryCatchPattern":"try {\n    parse.sourceInputStream(is);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"invalid: multiple sources\")) {\n        parse = bpmnParseFactory.createBpmnParse();\n    }\n}","preventionTips":["Create a new BpmnParse per parsed resource","Never chain two source* calls on one instance","Prefer the DeploymentBuilder API which manages BpmnParse lifecycle"],"tags":["bpmn","parsing","invalid-state"],"backgroundTag":"internal-invariant-violation","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"}