{"record":{"id":"01f1dc180dcd369c","repo":"flowable/flowable-engine","slug":"error-while-reading-the-dmn-xml-file","errorCode":null,"errorMessage":"Error while reading the dmn xml file","messagePattern":"Error while reading the dmn xml file","errorType":"exception","errorClass":"DmnXMLException","httpStatus":null,"severity":"error","filePath":"modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/xml/converter/DmnXMLConverter.java","lineNumber":251,"sourceCode":"        if (xif.isPropertySupported(XMLConstants.ACCESS_EXTERNAL_DTD)) {\n            xif.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, \"\");\n        }\n        \n        if (xif.isPropertySupported(XMLConstants.ACCESS_EXTERNAL_SCHEMA)) {\n            xif.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, \"\");\n        }\n\n        if (validateSchema) {\n            try (InputStreamReader in = new InputStreamReader(inputStreamProvider.getInputStream(), encoding)) {\n                if (!enableSafeDmnXml) {\n                    validateModel(inputStreamProvider);\n                } else {\n                    validateModel(xif.createXMLStreamReader(in));\n                }\n            } catch (UnsupportedEncodingException e) {\n                throw new DmnXMLException(\"The dmn xml is not properly encoded\", e);\n            } catch (XMLStreamException e) {\n                throw new DmnXMLException(\"Error while reading the dmn xml file\", e);\n            } catch (Exception e) {\n                throw new DmnXMLException(e.getMessage(), e);\n            }\n        }\n        // The input stream is closed after schema validation\n        try (InputStreamReader in = new InputStreamReader(inputStreamProvider.getInputStream(), encoding)) {\n            // XML conversion\n            return convertToDmnModel(xif.createXMLStreamReader(in));\n        } catch (UnsupportedEncodingException e) {\n            throw new DmnXMLException(\"The dmn xml is not properly encoded\", e);\n        } catch (XMLStreamException e) {\n            throw new DmnXMLException(\"Error while reading the dmn xml file\", e);\n        } catch (IOException e) {\n            throw new DmnXMLException(e.getMessage(), e);\n        }\n    }\n\n    public DmnDefinition convertToDmnModel(XMLStreamReader xtr) {","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/xml/converter/DmnXMLConverter.java#L233-L269","documentation":"During schema validation in convertToDmnModel, an XMLStreamException from creating/advancing the XMLStreamReader (e.g. xif.createXMLStreamReader(in) failing or the safe-XML reader erroring) is wrapped as DmnXMLException \"Error while reading the dmn xml file\".","triggerScenarios":"validateSchema=true and the XML reader cannot be created or advanced: malformed prolog, invalid XML declarations, or a reader-level failure before/while validateModel runs.","commonSituations":"Files that are not XML at all; XML with an invalid declaration line; corrupt stream from the InputStreamProvider; concurrent modification of the underlying resource during validation.","solutions":["Verify the file parses with xmllint or an IDE before conversion","Ensure the InputStreamProvider returns a valid, fresh stream","Check the XML declaration (encoding=...) matches the actual bytes","Inspect the wrapped XMLStreamException cause for the exact line/column"],"exampleFix":"// before\nInputStreamProvider p = () -> brokenCorruptStream;\n// after\nInputStreamProvider p = () -> new FileInputStream(new File(\"decision.dmn.xml\"));","handlingStrategy":"validation","validationCode":"try (InputStream in = provider.getInputStream()) { Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in); } catch (Exception e) { throw new IllegalStateException(\"DMN file unreadable: \" + e.getMessage(), e); }","typeGuard":null,"tryCatchPattern":"try { converter.convertToDmnModel(provider, true, true); } catch (DmnXMLException e) { if (e.getCause() instanceof XMLStreamException) { log.error(\"Cannot read dmn xml file\", e.getCause()); } }","preventionTips":["Keep validation enabled to fail fast with better messages","Ensure InputStreamProvider sources are stable and not concurrently modified","Check XML declarations match actual file encoding"],"tags":["xml","stream","parsing"],"backgroundTag":"xml-parse-error","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"}