{"record":{"id":"70e9edec5a6b762a","repo":"quarkusio/quarkus","slug":"data-error","errorCode":"DATA_ERROR","errorMessage":"Unable to convert DOMResult SQLXML data to a string.","messagePattern":"Unable to convert DOMResult SQLXML data to a string\\.","errorType":"error_code","errorClass":"PSQLException","httpStatus":null,"severity":"error","filePath":"extensions/jdbc/jdbc-postgresql/runtime/src/main/java/io/quarkus/jdbc/postgresql/runtime/graal/DomHelper.java","lineNumber":70,"sourceCode":"            return reallyProcessDomResult(domResult, conn);\n        } catch (SQLException e) {\n            throw new UncheckedSQLException(e);\n        }\n    }\n\n    // This XML processing code should only be reachable (via processDomResult function) iff it's\n    // actually used. I.e. setResult(Class) is reachable.\n    public static String reallyProcessDomResult(DOMResult domResult, BaseConnection conn) throws SQLException {\n        TransformerFactory factory = getXmlFactoryFactory(conn).newTransformerFactory();\n        try {\n            Transformer transformer = factory.newTransformer();\n            DOMSource domSource = new DOMSource(domResult.getNode());\n            StringWriter stringWriter = new StringWriter();\n            StreamResult streamResult = new StreamResult(stringWriter);\n            transformer.transform(domSource, streamResult);\n            return stringWriter.toString();\n        } catch (TransformerException te) {\n            throw new PSQLException(GT.tr(\"Unable to convert DOMResult SQLXML data to a string.\"),\n                    PSQLState.DATA_ERROR, te);\n        }\n    }\n\n    private static PGXmlFactoryFactory getXmlFactoryFactory(BaseConnection conn) throws SQLException {\n        if (conn != null) {\n            return conn.getXmlFactoryFactory();\n        }\n        return DefaultPGXmlFactoryFactory.INSTANCE;\n    }\n}\n\n@SuppressWarnings(\"serial\")\nfinal class UncheckedSQLException extends RuntimeException {\n\n    UncheckedSQLException(SQLException cause) {\n        super(cause);\n    }","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/jdbc/jdbc-postgresql/runtime/src/main/java/io/quarkus/jdbc/postgresql/runtime/graal/DomHelper.java#L52-L88","documentation":"DomHelper.reallyProcessDomResult() transforms a DOMResult (used when writing SQLXML data) to a string using a javax.xml Transformer. If the transformation fails with a TransformerException, a PSQLException with SQLState DATA_ERROR is thrown. This substitution exists because the default XML factory creation differs on GraalVM, and failures typically mean the XML transformer stack is unavailable or the DOM content is invalid.","triggerScenarios":"Calling SQLXML.setString/setCharacterStream-related DOMResult processing (e.g. via setString on a SQLXML from PgSQLXML) in native mode where the Transformer throws, e.g. missing Xalan/transformer implementation in the native image.","commonSituations":"Native-image apps writing XML to PostgreSQL SQLXML columns; missing XML transformer feature registration for GraalVM; malformed XML data supplied by the application.","solutions":["Register the JDK/Xalan transformer classes for reflection in the native image (registerFeature for javax.xml.transform implementations).","Validate that the XML string written to the SQLXML is well-formed before setting it.","Write XML as text (bytea/text column) instead of SQLXML if native transformer issues persist.","Catch PSQLException and inspect the chained TransformerException cause for the root XML problem."],"exampleFix":"// before\nsqlxml.setString(badXml); // TransformerException -> PSQLException DATA_ERROR\n// after\nif (isValidXml(badXml)) { sqlxml.setString(badXml); }","handlingStrategy":"try-catch","validationCode":"boolean wellFormed = true;\ntry { DocumentBuilderFactory.newInstance().newDocumentBuilder()\n        .parse(new InputSource(new StringReader(xml))); }\ncatch (Exception e) { wellFormed = false; }","typeGuard":null,"tryCatchPattern":"try {\n    sqlxml.setString(xml);\n} catch (PSQLException e) {\n    if (\"DATA_ERROR\".equals(e.getSQLState())) {\n        log.error(\"DOMResult transform failed; check XML well-formedness and native transformer registration\", e);\n    } else { throw e; }\n}","preventionTips":["Validate XML before writing to SQLXML columns","Register javax.xml.transform implementations for reflection in native images","Store XML in text/bytea columns if native XML support is not needed"],"tags":["postgresql","sqlxml","native-image","xml-transform"],"backgroundTag":"xml-transformation-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}