{"record":{"id":"90ef81dcfb19c671","repo":"flowable/flowable-engine","slug":"error-parsing-xml-90ef81","errorCode":null,"errorMessage":"Error parsing XML","messagePattern":"Error parsing XML","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/parser/BpmnParse.java","lineNumber":216,"sourceCode":"                        }\n\n                    }\n                }\n            }\n\n            bpmnModel.setSourceSystemId(sourceSystemId);\n            bpmnModel.setEventSupport(new FlowableEventSupport());\n\n            // Validation successful (or no validation)\n            transformProcessDefinitions();\n\n        } catch (Exception e) {\n            if (e instanceof ActivitiException) {\n                throw (ActivitiException) e;\n            } else if (e instanceof XMLException) {\n                throw (XMLException) e;\n            } else {\n                throw new ActivitiException(\"Error parsing XML\", e);\n            }\n        }\n\n        return this;\n    }\n\n    public BpmnParse name(String name) {\n        this.name = name;\n        return this;\n    }\n\n    public BpmnParse sourceInputStream(InputStream inputStream) {\n        if (name == null) {\n            name(\"inputStream\");\n        }\n        setStreamSource(new InputStreamSource(inputStream));\n        return this;\n    }","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/parser/BpmnParse.java#L198-L234","documentation":"BpmnParse.execute() wraps the whole XML parsing in a try/catch. Any exception that is neither an ActivitiException nor an XMLException (e.g. a low-level SAX/ParserConfigurationException/IOException) is wrapped in this generic 'Error parsing XML' ActivitiException with the original as cause.","triggerScenarios":"Malformed XML that crashes the underlying parser (unbalanced tags, encoding errors, invalid characters); parser factory misconfiguration (e.g. invalid SAXParserFactory); I/O errors while reading the stream source.","commonSituations":"Deploying truncated or corrupted .bpmn/.bpmn20.xml files; files with wrong encoding (e.g. UTF-16 declared/undeclared); XML features like DTDs or entities triggering parser failures; JDK XML parser differences across environments.","solutions":["Inspect the cause chain (e.getCause()) of the thrown ActivitiException to find the underlying parser error","Validate the XML is well-formed with an XML tool (xmllint / IDE validator) before deploying","Check file encoding and completeness; re-export or re-save the file as UTF-8","Compare JDK versions if the same file parses in one environment but not another"],"exampleFix":"// before: deploying a truncated file caught only at runtime\nrepositoryService.createDeployment().addClasspathResource(\"broken.bpmn20.xml\").deploy();\n// after: validate well-formedness first\nDocumentBuilderFactory f = DocumentBuilderFactory.newInstance();\nf.newDocumentBuilder().parse(new File(\"src/main/resources/broken.bpmn20.xml\")); // throws early with precise message","handlingStrategy":"try-catch","validationCode":"// cheap well-formedness check before deploy\ntry {\n  DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(bpmnXml)));\n} catch (SAXException | IOException e) {\n  throw new IllegalStateException(\"BPMN XML not well-formed: \" + e.getMessage());\n}","typeGuard":null,"tryCatchPattern":"try {\n  repositoryService.createDeployment().addInputStream(name, xml).deploy();\n} catch (ActivitiException e) {\n  if (\"Error parsing XML\".equals(e.getMessage())) {\n    Throwable cause = e.getCause(); // inspect SAX/IO/parser-config root cause\n  }\n}","preventionTips":["Check XML well-formedness and encoding (UTF-8) before deploying","Verify file completeness after transfers/generation","Pin consistent JDK versions across environments to avoid parser behavior differences"],"tags":["bpmn","xml","parsing","deployment"],"backgroundTag":"json-parse-error","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"}