{"record":{"id":"21d456642f0a27bd","repo":"flowable/flowable-engine","slug":"error-while-parsing-bpmn-model-21d456","errorCode":null,"errorMessage":"Error while parsing BPMN model.","messagePattern":"Error while parsing BPMN model\\.","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/diagram/ProcessDiagramLayoutFactory.java","lineNumber":110,"sourceCode":"        Map<String, DiagramElement> listOfBoundsForImage = transformBoundsForImage(diagramBoundsImage, diagramBoundsXml, listOfBounds);\n        return new DiagramLayout(listOfBoundsForImage);\n    }\n\n    protected Document parseXml(InputStream bpmnXmlStream) {\n        // Initiate DocumentBuilderFactory\n        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();\n        // Get one that understands namespaces\n        factory.setNamespaceAware(true);\n\n        DocumentBuilder builder;\n        Document bpmnModel;\n        try {\n            // Get DocumentBuilder\n            builder = factory.newDocumentBuilder();\n            // Parse and load the Document into memory\n            bpmnModel = builder.parse(bpmnXmlStream);\n        } catch (Exception e) {\n            throw new ActivitiException(\"Error while parsing BPMN model.\", e);\n        }\n        return bpmnModel;\n    }\n\n    protected DiagramNode getDiagramBoundsFromBpmnDi(Document bpmnModel) {\n        Double minX = null;\n        Double minY = null;\n        Double maxX = null;\n        Double maxY = null;\n\n        // Node positions and dimensions\n        NodeList setOfBounds = bpmnModel.getElementsByTagNameNS(BpmnParser.BPMN_DC_NS, \"Bounds\");\n        for (int i = 0; i < setOfBounds.getLength(); i++) {\n            Element element = (Element) setOfBounds.item(i);\n            Double x = Double.valueOf(element.getAttribute(\"x\"));\n            Double y = Double.valueOf(element.getAttribute(\"y\"));\n            Double width = Double.valueOf(element.getAttribute(\"width\"));\n            Double height = Double.valueOf(element.getAttribute(\"height\"));","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/diagram/ProcessDiagramLayoutFactory.java#L92-L128","documentation":"ProcessDiagramLayoutFactory.parseXml parses BPMN XML into a DOM Document using DocumentBuilder.parse to extract layout/diagram information. Any SAX/IO/parser failure is rethrown as ActivitiException('Error while parsing BPMN model.').","triggerScenarios":"Calling the diagram-layout generation APIs (e.g. getProcessDiagramLayout) with a stream that is not well-formed XML, unreadable, or closed.","commonSituations":"Passing a non-XML stream (e.g. PNG image) as the BPMN XML input; encoding mismatches; truncated file downloads; XML with undeclared entities.","solutions":["Validate the BPMN XML is well-formed (e.g. with xmllint) before calling the API","Ensure the InputStream is opened, readable, and positioned at the start","Check the XML declaration encoding matches the actual byte encoding"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();\nf.setNamespaceAware(true);\ntry { f.newDocumentBuilder().parse(new File(bpmnPath)); } catch (Exception e) { throw new IllegalStateException(\"BPMN XML invalid\", e); }","typeGuard":null,"tryCatchPattern":"try {\n    diagramLayout = factory.getProcessDiagramLayout(bpmnStream, imageStream);\n} catch (org.activiti.engine.ActivitiException e) {\n    if (e.getMessage().contains(\"Error while parsing BPMN model\")) {\n        // log e.getCause() and fall back to default layout\n    }\n}","preventionTips":["Validate BPMN XML with xmllint before calling layout APIs","Ensure streams are fresh, open and correctly encoded","Never pass an image stream where BPMN XML is expected"],"tags":["xml","parsing","bpmn"],"backgroundTag":"xml-parse-failed","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"}