quarkusio/quarkus · error · IllegalStateException
Stored XML element not found!
Error message
Stored XML element not found!
What it means
An IllegalStateException from the XML integration test's direct JDBC check that a row exists in the xmltest table. The SELECT 'SELECT val FROM xmltest' returned no rows, meaning the earlier writeXmlObject step did not persist anything or wrote to a different table/database.
Source
Thrown at integration-tests/jpa-postgresql-withxml/src/main/java/io/quarkus/it/jpa/postgresql/JPAFunctionalityTestEndpoint.java:148
@GET
@Path("datasource-xml")
public String datasourceXml() throws SQLException, TransformerException {
try (final Connection con = ds.getConnection()) {
deleteXmlSchema(con);
createXmlSchema(con);
writeXmlObject(con);
checkWrittenXmlObject(con);
}
return "OK";
}
private void checkWrittenXmlObject(Connection con) throws SQLException {
try (Statement stmt = con.createStatement()) {
final ResultSet resultSet = stmt.executeQuery("SELECT val FROM xmltest");
final boolean next = resultSet.next();
if (!next) {
throw new IllegalStateException("Stored XML element not found!");
}
final String storedValue = resultSet.getString(1);
if (storedValue == null) {
throw new IllegalStateException("Stored XML element was loaded as null!");
}
String expectedMatch = "<?xml version=\"1.0\" standalone=\"no\"?><root><ele>1</ele><ele>2</ele></root>";
if (!expectedMatch.equals(storedValue)) {
throw new IllegalStateException("Stored XML element is not matching expected value of '" + expectedMatch
+ "', but was '" + storedValue + "'");
}
}
}
private void writeXmlObject(Connection con) throws SQLException, TransformerException {
TransformerFactory factory = TransformerFactory.newInstance();
final String _xmlDocument = "<root><ele>1</ele><ele>2</ele></root>";
Transformer identityTransformer = factory.newTransformer();
try (PreparedStatement ps = con.prepareStatement("INSERT INTO xmltest VALUES (?,?)")) {View on GitHub (pinned to e1c734241f)
Solutions
- Ensure writeXmlObject commits before checkWrittenXmlObject runs (same transaction or committed connection)
- Verify both methods use the same datasource/connection to the same database
- Check the INSERT in writeXmlObject actually executed (look for swallowed SQLExceptions)
Example fix
// before
try (Statement stmt = con.createStatement()) {
final ResultSet rs = stmt.executeQuery("SELECT val FROM xmltest");
if (!rs.next()) { throw new IllegalStateException("Stored XML element not found!"); }
// after
try (Statement stmt = con.createStatement()) {
final ResultSet rs = stmt.executeQuery("SELECT val FROM xmltest ORDER BY 1 LIMIT 1");
assertTrue(rs.next(), "xmltest table empty - did the write transaction commit?"); Defensive patterns
Strategy: validation
Validate before calling
try (Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT count(*) FROM xmltest")) {
rs.next();
boolean tableHasData = rs.getInt(1) > 0;
} Prevention
- Commit the write connection before checking with another statement
- Use the same connection/transaction for write and read checks in tests
- Fail fast: assert INSERT affected 1 row in writeXmlObject
When it happens
Trigger: checkWrittenXmlObject(Connection) runs resultSet.next() on the xmltest query and gets false - the INSERT in writeXmlObject never committed or the table is empty at check time.
Common situations: Transaction isolation/commit ordering issues between write and check connections, wrong datasource checked, or a prior test step that deleted the row.
Related errors
- UNEXPECTED_ERROR
- Stored XML element was loaded as null!
- OBJECT_NOT_IN_STATE
- Default mapper cannot process date/time properties. So we we
- flush failed for a different reason than expected.
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/9513099457abed42.
Report an issue: GitHub.