Hi,

UUID is not required to be supported by the JSON-B spec 
(https://jakarta.ee/specifications/jsonb/3.0/jakarta-jsonb-spec-3.0#default-mapping),
 so Johnzon does not implement it. As far as I can tell from skimming over 
filenames in yasson it seems like they do however support it, hence your 
example works everywhere else (AFAIK TomEE is the only application server that 
uses Johnzon)

You need to create a JsonbAdapter for this to reliably work and register it 
either globally in JAX-RS with a ContextResolver<Jsonb> (this could cause 
issues e.g. in tests/when you use the models outside of JAX-RS) or use it in 
your model classes with @JsonbTypeAdapter which is what I would prefer


Thanks

Markus

> On 4. Apr 2025, at 16:35, hantsy bai <han...@gmail.com> wrote:
> 
> Hi
> Special thanks to Richard Zowalla for helping me resolve some issues of the
> TomEE and Aruqillian configuration.
> 
> Another issue I found in the Github actions log is the serialization issue
> of UUID, TomEE used Apache Johnzon as JSON-B implementation.
> 
> ```
> Caused by: jakarta.json.bind.JsonbException: Todo property 'id' of type ID
> cannot be mapped to json object value:
> {"leastSignificantBits":-5668611215224300934,"most...
> UUID has no suitable constructor or factory. Cannot deserialize json object
> value: {"leastSignificantBits":-5668611215224300934,"most...
> Use Johnzon @ConstructorProperties or @JsonbCreator if constructor
> arguments are needed
> class java.util.UUID not instantiable
> at org.apache.johnzon.jsonb.JohnzonJsonb.fromJson(JohnzonJsonb.java:253)
> at
> org.glassfish.jersey.jsonb.internal.JsonBindingProvider.readFrom(JsonBindingProvider.java:91)
> 
> ... 58 more
> ```
> 
> Check the complete log here:
> https://github.com/hantsy/jakartaee10-starter-boilerplate/actions/runs/14233160351/job/39887609042#step:4:1657
> 
> Do we need extra configuration to enable UUID support in Johnzon?
> 
> ---
> 
> Regards,
> 
> *Hantsy Bai*
> 
> Self-employed consultant, fullstack developer, agile coach,
> freelancer/remote worker
> 
> GitHub: https://github.com/hantsy
> 
> Twitter: https://twitter.com/@hantsy
> Medium: https://medium.com/@hantsy

Reply via email to