faisalloe opened a new issue, #5140:
URL: https://github.com/apache/camel-k/issues/5140
### What happened?
I migrated project from Camel v2.x to Camel v3.14.10, I have single
ObjectMapper configured used across entire application debugging camel-jack
source code come to find out by default camel won't pickup @primary @Bean
declared ObjectMapper unless we set "autoDiscoverObjectMapper" property to
true. I can't find any way to setup autoDiscoverObjectMapper globally without
spring-boot. I use simple spring 5.x MVC without spring boot. every single
example I found to configure autoDiscoverObjectMapper property globally using
camel-starter-x dependency which is spring-boot library. either it is a bug not
to able to configure autoDiscoverObjectMapper property globally so that every
time camel create JacksonDataFormat will inject primary ObjectMapper
automatically.
### Steps to reproduce
I have this configuration working fine with camel v2.x but when I upgrade
camel to v3.14.x I start to get following error. ..
Error During Camel route Processing - Java 8 date/time type
'java.time.LocalDate' not supported by default add module
"com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
```
@Configuration
public class CamelConfiguration extends CamelConfiguration{
@override
public void setupCamelContext(CamelContext context){
context.setAllowOriginalMessage(false);
context.setLogMask(true);
context.setAutoStartup(false);
}
@Bean
public CamelRoutesStarter routesStarter(CamelContext context){
return new CamelRoutesStarter(context)
}
}
@Configuration
public class serviceConfig {
@primary
@Bean
public ObjectMapper objectMapper(){
Jackson2Obj ectMapperBuilder.json().serializationIncludsion(non_empty)
.featureToDisable(WRITE_DATES_AS_TIMESTAMPS).deserializerByType(LocalDate.class,
new CustomDateDeserialier())
}
}
@override
public class CustomDateDeserialier extends StdScalarDeserilaizer<LocalDate>{
public LocalDate deserialize(JsonParser parser, DeseralizationContext
context){
..
}
}
// my camel route
@Component
public MyRoute{
from("my http request")
.unmarshal().json(Jackson, Model.class)
.to("bla bla");
}
// my model
public class Model {
public LocalDate date;
}
```
**instead if I try following it works.** how would I configure
autoDiscoverObjectMapper globally to inject my ObjectMapper automatically into
JsonDataFormat.
```
@Component
public MyModifiedRoute{
@Autowire
private ObjectMapper mapper;
private JacksonDataFormat dataFmt;
@PostConstruct()
public void post(){
dataFmt = new JacksonDataFormat(mapper, Model.class)
}
from("my http request")
.unmarshal(dataFmt) //.json(Jackson, Model.class)
.to("bla bla");
}
}
```
### Relevant log output
_No response_
### Camel K version
camel v3.14.10
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]