{"record":{"id":"4e320c96eda814a9","repo":"flowable/flowable-engine","slug":"error-reading-xml","errorCode":null,"errorMessage":"Error reading XML","messagePattern":"Error reading XML","errorType":"exception","errorClass":"XMLException","httpStatus":null,"severity":"error","filePath":"modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/BpmnXMLConverter.java","lineNumber":331,"sourceCode":"            throw new XMLException(\"Error while reading the BPMN 2.0 XML\", e);\n        } catch (IOException e) {\n            throw new XMLException(e.getMessage(), e);\n        }\n    }\n\n    public BpmnModel convertToBpmnModel(XMLStreamReader xtr) {\n        BpmnModel model = new BpmnModel();\n        model.setStartEventFormTypes(startEventFormTypes);\n        model.setUserTaskFormTypes(userTaskFormTypes);\n        try {\n            Process activeProcess = new Process();\n            List<SubProcess> activeSubProcessList = new ArrayList<>();\n            while (xtr.hasNext()) {\n                try {\n                    xtr.next();\n                } catch (Exception e) {\n                    LOGGER.debug(\"Error reading XML document\", e);\n                    throw new XMLException(\"Error reading XML\", e);\n                }\n\n                if (xtr.isEndElement() && (ELEMENT_SUBPROCESS.equals(xtr.getLocalName()) ||\n                        ELEMENT_TRANSACTION.equals(xtr.getLocalName()) ||\n                        ELEMENT_ADHOC_SUBPROCESS.equals(xtr.getLocalName()))) {\n\n                    activeSubProcessList.remove(activeSubProcessList.size() - 1);\n                }\n\n                if (!xtr.isStartElement()) {\n                    continue;\n                }\n\n                if (ELEMENT_DEFINITIONS.equals(xtr.getLocalName())) {\n                    definitionsParser.parse(xtr, model);\n\n                } else if (ELEMENT_RESOURCE.equals(xtr.getLocalName())) {\n                    resourceParser.parse(xtr, model);","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/BpmnXMLConverter.java#L313-L349","documentation":"Inside convertToBpmnModel(XMLStreamReader), each xtr.next() pull is wrapped: if advancing the StAX cursor throws, the converter logs at debug and throws XMLException(\"Error reading XML\"). This means the XML token stream broke mid-iteration while walking the BPMN document.","triggerScenarios":"convertToBpmnModel(XMLStreamReader) iterating xtr.hasNext()/next() when the underlying reader encounters malformed content, an unexpected end of document, or I/O failure from the source stream partway through parsing.","commonSituations":"Same mid-document corruption as other parse errors: truncated uploads, invalid characters after a valid prefix, or a reader built over a network stream that dropped mid-read.","solutions":["Enable debug logging for BpmnXMLConverter to see the logged 'Error reading XML document' stack trace with parser location.","Repair the malformed XML at the reported location.","Serve the converter from a complete, local (non-streaming) byte source so partial reads can't happen.","Re-export the BPMN file from its authoring tool."],"exampleFix":"// before\nXMLStreamReader xtr = factory.createXMLStreamReader(socket.getInputStream());\n// after\nbyte[] full = readFully(socket.getInputStream()); // ensure complete document before parsing\nXMLStreamReader xtr = factory.createXMLStreamReader(new ByteArrayInputStream(full));","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    BpmnModel model = converter.convertToBpmnModel(xtr);\n} catch (XMLException e) {\n    if (\"Error reading XML\".equals(e.getMessage())) {\n        // token stream broke mid-iteration; full cause logged at debug by the converter\n        log.debug(\"StAX cursor failed mid-document\", e);\n    }\n    throw new DeploymentException(\"BPMN document unreadable\", e);\n}","preventionTips":["Enable DEBUG logging on BpmnXMLConverter to capture the underlying parser error location","Parse from a complete in-memory byte array, not a live network stream","Validate documents with a DOM/SAX pass before StAX conversion"],"tags":["java","xml","stax","bpmn"],"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-14T05:17:10.506Z"}