Hi,

Can you provide a reproducer? one thing that pops up from the environment
description is the Spring Boot version, in particular, with Camel 4.5.0,
you should use Spring Boot 3.2.5, can you update the spring boot version
and try again?

Il giorno gio 16 mag 2024 alle ore 10:57 Ghassen Kahri <
ghassen.ka...@codeonce.fr> ha scritto:

> Hi folks,
>
> I am encountering an issue while migrating from Camel 4.0.3 to Camel 4.5.0.
> Below is my Jackson configuration class:
>
> @Configuration
> public class JacksonConfiguration {
>
>     @Primary
>     @Bean("json-mapper")
>     public ObjectMapper objectMapper() { return configure(new
> ObjectMapper()); }
>
>     @Bean
>     @Primary
>     public JacksonDataFormatConfiguration jacksonDataFormatConfiguration()
> {
>         JacksonDataFormatConfiguration config = new
> JacksonDataFormatConfiguration();
>         config.setObjectMapper("json-mapper");
>         return config;
>     }
>
>     private ObjectMapper configure(ObjectMapper mapper) {
>         return mapper
>                 .setSerializationInclusion(NON_NULL)
>
> .setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE)
>                 .enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS)
>                 .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
>                 .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
>
> .disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)
>                 .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
>                 .registerModule(new JavaTimeModule())
>                 .registerModule(new Jdk8Module())
>                 .registerModule(new GuavaModule())
>                 .findAndRegisterModules();
>     }
> }
>
> In the new version, I get an error indicating that Camel cannot deserialize
> Optional<Integer> when using .unmarshal().json(JsonLibrary.Jackson,
> XXX.class). Upon debugging, I discovered that Camel requires the Jdk8Module
> for this operation. It seems that my Jackson configuration is not being
> scanned in the application.
>
> Using the following syntax in my route resolves the error:
>
> JacksonDataFormat jacksonDataFormat = new JacksonDataFormat(XXX.class);
> jacksonDataFormat.setObjectMapper(objectMapper);
> .
> .
> .
> .unmarshal(jacksonDataFormat);
>
> Do I need to explicitly import my configuration each time I need to
> deserialize a POJO?
>
> Old Environment:
>
>    - Camel: 4.0.3
>    - Spring Boot: 3.1.6
>    - Java: 17
>
> New Environment:
>
>    - Camel: 4.5.0
>    - Spring Boot: 3.1.6
>    - Java: 17
>

Reply via email to