Currently we are migrating our applications from Camel 2.x to Camel 3.x and faced an issue that JacksonDataFormat
is not using an ObjectMapper
from the application context by default anymore. Instead you need to provide a property camel.dataformat.json-jackson.auto-discover-object-mapper=true
for this feature to work. I don't understand why this is not equal to true
by default for the camel-jackson-starter
module, this seems illogical to me. Probably someone knows the reason behind this?
Apache Camel is modifying ObjectMapper
bean properties depending on your JacksonDataFormat
definition. This is really confusing, if seemingly irrelevant DataFormat
definition is changing your singleton ObjectMapper
bean in registry, which you might have configured for different part of your application. This could be unexpected for some developers, so it has been decided to fail-fast during startup.
If you are using more than one JacksonDataFormat
definition, never set camel.dataformat.json-jackson.auto-discover-object-mapper=true
. You will see some strange behavior, which will be extremely hard to debug.
See CAMEL-14101:
The current default behaviour of the json-jackson data format is to try to lookup an ObjectMapper instance to the registry and if not found to create a new one. In case one is found, the data format instance does customize it according to its local properties but as the same ObjectMapper instance could be shared among different json-jackson data formats, it may lead to inconsistencies or unpredictable behaviors.