Spring Boot 4: enabled webclient replaces the host application's Jackson 3 JSON converter with a Jackson 2 converter #56
Unanswered
daniel-beguelin
asked this question in
Q&A
Replies: 1 comment
|
I think the issue is that the webclient registers its Jackson 2 converter for the whole MVC application, which can override Spring Boot 4’s Jackson 3 converter and break host DTOs that use |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Environment
cibseven-bpm-spring-boot-starter-4,-rest-4,-webapp-4)cibseven.webclient.enabled=true@RestControllers) next to the embedded engine and webclient.Problem
With the webclient enabled, all JSON responses of the host application are written by the webclient's
Jackson 2 converter instead of Spring Boot's auto-configured Jackson 3 converter. Our API DTOs use
java.util.Optionalfields, which that Jackson 2 mapper cannot handle, so every such response fails:With
cibseven.webclient.enabled=falsethe same application works (MVC uses Boot'sJacksonJsonHttpMessageConverter).Cause (as far as we can tell)
CamundaBpmWebappAutoConfigurationimportsorg.cibseven.webapp.SevenWebclientContextwhen thewebclient is enabled (in the Boot 4 jar
cibseven-webclient-web-spring-boot-4it is additionally listedin
AutoConfiguration.imports).SevenWebclientContextis aWebMvcConfigurerand configures themessage converters of the whole MVC application: it seems to replace the JSON converter, so Boot's Jackson 3 converter is gone for every endpoint of the host application, not only for the webclient's own endpoints.
Reproduction
-4starters andcibseven.webclient.enabled=true.@RestControllerreturning a DTO with anOptional<String>field (e.g. as generated byopenapi-generator with
useOptional=true).cibseven.webclient.enabled=false→ 200.Workaround we use
Put Boot's Jackson 3 converter in front of the webclient's converter and let it decline Jackson 2 types,
so the webclient's
ObjectNode/JsonNoderesponses still go to its own Jackson 2 converter:With this, both the host application's API (Jackson 3,
Optionalunwrapped) and the webclient(login, Cockpit,
info/properties) work.Questions / suggestions
Is it intended that the embedded webclient changes the JSON converter of the host application? This prevents the use of Jackson 3, which is the recommended version in Spring Boot 4.0.8. We suggest to scope the Jackson configuration of the embedded component to its own controllers only.
All reactions