quarkusio/quarkus · warning · UnsupportedOperationException
I cannot convert anything from JSON.
Error message
I cannot convert anything from JSON.
What it means
This UnsupportedOperationException is deliberately thrown by a custom Hibernate 6 FormatMapper (JSON) registered via @PersistenceUnitExtension("other") in a Quarkus integration test. The test PU intentionally has no working JSON conversion so that any attempt to read a JSON property from that persistence unit fails loudly. It is not a bug in a library but an intentional sentinel in the test codebase.
Source
Thrown at integration-tests/jpa-postgresql/src/main/java/io/quarkus/it/jpa/postgresql/otherpu/JsonFormatMapper.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.JsonFormat;
import io.quarkus.hibernate.orm.PersistenceUnitExtension;
@JsonFormat
@PersistenceUnitExtension("other")
public class JsonFormatMapper implements FormatMapper {
@Override
public <T> T fromString(CharSequence charSequence, JavaType<T> javaType, WrapperOptions wrapperOptions) {
throw new UnsupportedOperationException("I cannot convert anything from JSON.");
}
@Override
public <T> String toString(T value, JavaType<T> javaType, WrapperOptions wrapperOptions) {
throw new UnsupportedOperationException("I cannot convert anything to JSON.");
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Use a real FormatMapper implementation (e.g. JacksonJsonFormatMapper) instead of this test stub
- Remove the @PersistenceUnitExtension("other") JsonFormatMapper so Hibernate's default JSON mapper is used
- If this is your own stub, implement fromString with an actual mapper (Jackson ObjectMapper) instead of throwing
Example fix
// before
public <T> T fromString(CharSequence charSequence, JavaType<T> javaType, WrapperOptions wrapperOptions) {
throw new UnsupportedOperationException("I cannot convert anything from JSON.");
}
// after
public <T> T fromString(CharSequence charSequence, JavaType<T> javaType, WrapperOptions wrapperOptions) {
return objectMapper.readValue(charSequence.toString(), objectMapper.constructType(javaType.getJavaType()));
} Defensive patterns
Strategy: try-catch
Validate before calling
boolean canRead = mapper != null && !(mapper instanceof JsonFormatMapper);
Try / catch
try {
T value = mapper.fromString(json, javaType, options);
} catch (UnsupportedOperationException e) {
throw new IllegalStateException("PU has no JSON read support: " + e.getMessage(), e);
} Prevention
- Never reuse test throwing-stub mappers in production code
- Register a real FormatMapper (Jackson) for any PU that maps JSON columns
- Add a startup smoke test that reads one JSON attribute per PU
When it happens
Trigger: Any code path that materializes an entity attribute mapped as JSON (FormatMapper#toString/fromString contract) for the 'other' persistence unit, causing Hibernate to call JsonFormatMapper.fromString to convert a DB JSON string into a Java object.
Common situations: Seen only when running the jpa-postgresql integration tests that use the secondary PU; a developer copying this mapper into a real application will hit it whenever Hibernate ORM needs JSON <-> Java conversion for Json/JsonJavaType attributes.
Related errors
- I cannot convert anything to JSON.
- flush failed for a different reason than expected.
- I cannot convert anything from XML.
- I cannot convert anything to XML.
- Json array ended without ]
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/153c82bc1abbcf85.
Report an issue: GitHub.