quarkusio/quarkus · error · UnsupportedOperationException
I cannot convert anything from XML.
Error message
I cannot convert anything from XML.
What it means
XmlFormatMapper.fromString unconditionally throws UnsupportedOperationException('I cannot convert anything from XML.'). This mapper is a deliberately degenerate FormatMapper registered via @PersistenceUnitExtension("other") with @XmlFormat for the 'other' persistence unit; it is used by the integration test to prove that Hibernate calls the custom mapper. Any code path that deserializes an XML-format column value from that persistence unit will always fail with this exception.
Source
Thrown at integration-tests/jpa-postgresql-withxml/src/main/java/io/quarkus/it/jpa/postgresql/otherpu/XmlFormatMapper.java:16
package io.quarkus.it.jpa.postgresql.otherpu;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.format.FormatMapper;
import io.quarkus.hibernate.orm.PersistenceUnitExtension;
import io.quarkus.hibernate.orm.XmlFormat;
@XmlFormat
@PersistenceUnitExtension("other")
public class XmlFormatMapper implements FormatMapper {
@Override
public <T> T fromString(CharSequence charSequence, JavaType<T> javaType, WrapperOptions wrapperOptions) {
throw new UnsupportedOperationException("I cannot convert anything from XML.");
}
@Override
public <T> String toString(T value, JavaType<T> javaType, WrapperOptions wrapperOptions) {
throw new UnsupportedOperationException("I cannot convert anything to XML.");
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Do not use XmlFormatMapper in production code — it is a test-only mapper that intentionally fails
- Implement fromString properly in your custom FormatMapper (e.g. parse the CharSequence with a real XML/JSON parser)
- Check the @PersistenceUnitExtension qualifier so the real mapper, not the throwing test one, is bound to your persistence unit
- If reading should be supported but writing not, implement fromString and keep throwing only in toString
Example fix
// before
@Override
public <T> T fromString(CharSequence charSequence, JavaType<T> javaType, WrapperOptions wrapperOptions) {
throw new UnsupportedOperationException("I cannot convert anything from XML.");
}
// after
@Override
public <T> T fromString(CharSequence charSequence, JavaType<T> javaType, WrapperOptions wrapperOptions) {
return (T) xmlMapper.readValue(charSequence.toString(), javaType.getJavaClass());
} Defensive patterns
Strategy: try-catch
Validate before calling
// Check which FormatMapper is bound to your persistence unit before relying on XML reads
if (formatMapper instanceof XmlFormatMapper) {
throw new IllegalStateException("Test-only XmlFormatMapper is active; XML reads are not supported");
} Type guard
static boolean supportsReading(FormatMapper mapper) {
return !(mapper instanceof XmlFormatMapper);
} Try / catch
try {
EntityWithXmlOtherPU e = em.find(EntityWithXmlOtherPU.class, id);
} catch (UnsupportedOperationException e) {
if (e.getMessage() != null && e.getMessage().contains("I cannot convert anything from XML")) {
// fall back to a working mapper or raw column read
} else {
throw e;
}
} Prevention
- Never ship test-only mappers annotated with @PersistenceUnitExtension in production artifacts
- Implement both directions (toString/fromString) in production FormatMapper implementations
- Verify mapper selection per persistence unit during development with a smoke read/write test
- Document intentionally unsupported directions in the mapper instead of throwing bare UnsupportedOperationException
When it happens
Trigger: Reading (deserializing) an entity property that Hibernate maps with the XML format mapper from the 'other' persistence unit — e.g. loading an EntityWithXmlOtherPU row whose property must be converted from the stored string back to Java via fromString.
Common situations: Queries that select entities with @JdbcTypeCode(SqlTypes.JSON)-style XML-mapped properties from the 'other' PU; accidentally wiring this test mapper (or copying it) into a real application PU where XML conversion should actually work.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- I cannot convert anything to XML.
- This isn't used for schema generation - see SessionFactoryOb
- This method is not available at runtime in Quarkus
- I cannot convert anything from JSON.
- I cannot convert anything to JSON.
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/cb2685ba70052046.
Report an issue: GitHub.