question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Quarkus ignores mapped jackson annotations of 3rd party libraries

See original GitHub issue

Describe 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:

  1. include any library which uses jersey with jackson annotated classes to unmarshall a jackson annotated class
  2. use jsonb for your main application
  3. 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:closed
  • Created 4 years ago
  • Comments:30 (16 by maintainers)

github_iconTop GitHub Comments

2reactions
gsmetcommented, Dec 15, 2019

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.

1reaction
rmannibucaucommented, Dec 17, 2019

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tips for writing native applications - Quarkus
Using the @RegisterForReflection annotation ... If your class is in a third-party jar, you can do it by using an empty class that...
Read more >
Writing Your Own Extension - Quarkus
Quarkus extensions add a new developer focused behavior to the core offering, and consist of two distinct parts, buildtime augmentation and runtime ...
Read more >
All configuration options - Quarkus
AWS Lambda Type Default AWS Lambda Common Type Default AWS Lambda Gateway REST API Type Default Agroal ‑ Database connection pool Type Default
Read more >
Writing JSON REST Services - Quarkus
In Quarkus, the default Jackson ObjectMapper obtained via CDI (and consumed by the Quarkus extensions) is configured to ignore unknown properties (by disabling ......
Read more >
Application Data Caching - Quarkus
The problem is that you have to rely on an external meteorological ... The @CacheKey annotations that might be present on some method...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found