quarkusio/quarkus · error · PSQLException
DATA_ERROR
DATA_ERROR
Error message
Unable to convert DOMResult SQLXML data to a string.
What it means
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.
Source
Thrown at extensions/jdbc/jdbc-postgresql/runtime/src/main/java/io/quarkus/jdbc/postgresql/runtime/graal/DomHelper.java:70
return reallyProcessDomResult(domResult, conn);
} catch (SQLException e) {
throw new UncheckedSQLException(e);
}
}
// This XML processing code should only be reachable (via processDomResult function) iff it's
// actually used. I.e. setResult(Class) is reachable.
public static String reallyProcessDomResult(DOMResult domResult, BaseConnection conn) throws SQLException {
TransformerFactory factory = getXmlFactoryFactory(conn).newTransformerFactory();
try {
Transformer transformer = factory.newTransformer();
DOMSource domSource = new DOMSource(domResult.getNode());
StringWriter stringWriter = new StringWriter();
StreamResult streamResult = new StreamResult(stringWriter);
transformer.transform(domSource, streamResult);
return stringWriter.toString();
} catch (TransformerException te) {
throw new PSQLException(GT.tr("Unable to convert DOMResult SQLXML data to a string."),
PSQLState.DATA_ERROR, te);
}
}
private static PGXmlFactoryFactory getXmlFactoryFactory(BaseConnection conn) throws SQLException {
if (conn != null) {
return conn.getXmlFactoryFactory();
}
return DefaultPGXmlFactoryFactory.INSTANCE;
}
}
@SuppressWarnings("serial")
final class UncheckedSQLException extends RuntimeException {
UncheckedSQLException(SQLException cause) {
super(cause);
}View on GitHub (pinned to e1c734241f)
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.
Example fix
// before
sqlxml.setString(badXml); // TransformerException -> PSQLException DATA_ERROR
// after
if (isValidXml(badXml)) { sqlxml.setString(badXml); } Defensive patterns
Strategy: try-catch
Validate before calling
boolean wellFormed = true;
try { DocumentBuilderFactory.newInstance().newDocumentBuilder()
.parse(new InputSource(new StringReader(xml))); }
catch (Exception e) { wellFormed = false; } Try / catch
try {
sqlxml.setString(xml);
} catch (PSQLException e) {
if ("DATA_ERROR".equals(e.getSQLState())) {
log.error("DOMResult transform failed; check XML well-formedness and native transformer registration", e);
} else { throw e; }
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Native-image apps writing XML to PostgreSQL SQLXML columns; missing XML transformer feature registration for GraalVM; malformed XML data supplied by the application.
Related errors
- DATA_ERROR
- INVALID_PARAMETER_TYPE
- The org.postgresql.sspi.SSPIClient is not available on Graal
- UNEXPECTED_ERROR
- OBJECT_NOT_IN_STATE
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/70e9edec5a6b762a.
Report an issue: GitHub.