{"record":{"id":"153c82bc1abbcf85","repo":"quarkusio/quarkus","slug":"i-cannot-convert-anything-from-json","errorCode":null,"errorMessage":"I cannot convert anything from JSON.","messagePattern":"I cannot convert anything from JSON\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"warning","filePath":"integration-tests/jpa-postgresql/src/main/java/io/quarkus/it/jpa/postgresql/otherpu/JsonFormatMapper.java","lineNumber":16,"sourceCode":"package io.quarkus.it.jpa.postgresql.otherpu;\n\nimport org.hibernate.type.descriptor.WrapperOptions;\nimport org.hibernate.type.descriptor.java.JavaType;\nimport org.hibernate.type.format.FormatMapper;\n\nimport io.quarkus.hibernate.orm.JsonFormat;\nimport io.quarkus.hibernate.orm.PersistenceUnitExtension;\n\n@JsonFormat\n@PersistenceUnitExtension(\"other\")\npublic class JsonFormatMapper implements FormatMapper {\n\n    @Override\n    public <T> T fromString(CharSequence charSequence, JavaType<T> javaType, WrapperOptions wrapperOptions) {\n        throw new UnsupportedOperationException(\"I cannot convert anything from JSON.\");\n    }\n\n    @Override\n    public <T> String toString(T value, JavaType<T> javaType, WrapperOptions wrapperOptions) {\n        throw new UnsupportedOperationException(\"I cannot convert anything to JSON.\");\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/integration-tests/jpa-postgresql/src/main/java/io/quarkus/it/jpa/postgresql/otherpu/JsonFormatMapper.java#L1-L24","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\npublic <T> T fromString(CharSequence charSequence, JavaType<T> javaType, WrapperOptions wrapperOptions) {\n    throw new UnsupportedOperationException(\"I cannot convert anything from JSON.\");\n}\n// after\npublic <T> T fromString(CharSequence charSequence, JavaType<T> javaType, WrapperOptions wrapperOptions) {\n    return objectMapper.readValue(charSequence.toString(), objectMapper.constructType(javaType.getJavaType()));\n}","handlingStrategy":"try-catch","validationCode":"boolean canRead = mapper != null && !(mapper instanceof JsonFormatMapper);","typeGuard":null,"tryCatchPattern":"try {\n    T value = mapper.fromString(json, javaType, options);\n} catch (UnsupportedOperationException e) {\n    throw new IllegalStateException(\"PU has no JSON read support: \" + e.getMessage(), e);\n}","preventionTips":["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"],"tags":["hibernate-orm","json","format-mapper","test-stub"],"backgroundTag":"unsupported-operation-stub","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}