Quarkus ignores mapped jackson annotations of 3rd party libraries
See original GitHub issueDescribe the bug
I included a 3rd party library in my application. This library makes use of Jackson
and Jersey
for its rest webservices and json-(un)marshallings. My main application uses Json-B
annotated classes and I included the quarkus-resteasy-jsonb
in my pom.xml
. However, with such configuration, quarkus totally ignores the jackson-mappings from the 3rd-party library and tries to unmarshall it by Json-B
even if these classes does not contain any Json-B
annotations. The bug is also described in https://github.com/quarkusio/quarkus/issues/5906.
To sum up:
- If you use a 3rd party dependency which uses jackson under the hood, then your application must also use jackson.
- If you use json-b in your application and one of your dependencies uses jackson, then these dependencies will not work in Quarkus and can lead to wrong (un)marshallings or unexpected error logs
- It will also not work, if you use two dependencies, one using jackson and the other using json-b internally even if your main application does not use jackson or json-b.
- It only works if both your application or any dependency has the same json-provider, either json-b or jackson.
Expected behavior The mapped jackson-annotations (or jsonb-annotations) of a 3rd party library must be considered instead of ignoring them and trying to (un)marshalling it with the json-provider of the main application.
Actual behavior All 3rd party libraries using jackson or jsonb under the hood and which does not comply with the json-provider of the main application can lead to wrong (un)marshallings or unexpected error logs. Quarkus totally ignores the mappings of any 3rd party dependency - for the user this is not obviously recognizable because the mappings are hidden in the 3rd party library.
To Reproduce Steps to reproduce the behavior:
- include any library which uses jersey with jackson annotated classes to unmarshall a jackson annotated class
- use jsonb for your main application
- try to use the 3rd party library - you will see that your jackson annotations are ignored and the mapping is tried by using jsonb (even if the author of the 3rd party library does not intended the use of jsonb for its classes)
Environment (please complete the following information):
- Output of
java -version
: 12 - Quarkus version or git rev: 1.0 Final
Additional context There are a lot of 3rd party dependencies making use of jackson as its json-provider. There are also more and more 3rd party dependencies making use of jsonb as its json-provider. Actually, in Quarkus you cannot include them togheter in pom.xml.
Issue Analytics
- State:
- Created 4 years ago
- Comments:30 (16 by maintainers)
Well, you apparently have the time to open a lot of issues. So please take the time to provide a reproducer if you want us to investigate. If not, that’s your choice.
It’s typically the type of issue where we will spend hours shooting in the dark.
@nimo23 implement your own ClientBuilder (it is a SPI), exclude default one (only the registration file from meta-inf) and register the default providers you want there delegating the logic to your default impl. Will be a workaround for such hybrid cases.