1

I have a small service based on Thorntail and Microprofile. It seems pretty simple - get the JSON in the POST request do some stuff, return the response. The issue though, in a POJO I have a LocalDateTime field and there things go awry, here's the response I get

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct
 instance of `java.time.LocalDateTime` (no Creators, like default construct,
 exist): no String-argument constructor/factory method to deserialize from
 String value ('2020-04-28T04:10:48.020Z')
 at [Source: (io.undertow.servlet.spec.ServletInputStreamImpl); line: 1,
 column: 496] (through reference chain:
 com.ainq.pulse.audit.model.UserAuditEvent["timestamp"])

Why it uses Jackson instead of Jsonb provider ?

In the log I get following message (among others)

2020-04-28 10:19:37,235 WARN  [org.jboss.as.jaxrs] (MSC service thread 1-6) 
WFLYRS0018: Explicit usage of Jackson annotation in a JAX-RS deployment; the
 system will disable JSON-B processing for the current deployment. Consider 
setting the 'resteasy.preferJacksonOverJsonB' property to 'false' to restore
 JSON-B.

Where do I set this resteasy.preferJacksonOverJsonB propert ?
I have tried to set property in project-defaults.yml, i have tried to supply as a -D argument, nothing seems to work and I still get this message and I still have issues with (de)serializing.

What is the way to fix it ? I looked at the documentation, examples and even source code, still have to idea what would work.

UPDATE:

Relevant part from dependency:tree

[INFO] +- io.thorntail:microprofile:jar:2.6.0.Final:compile
[INFO] |  +- io.thorntail:jaxrs:jar:2.6.0.Final:compile
[INFO] |  |  +- io.thorntail:jaxrs-cdi:jar:2.6.0.Final:compile
[INFO] |  |  +- org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_2.1_spec:jar:2.0.0.Final:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-core:jar:2.9.10:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.10:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.10.1:compile
[INFO] |  |  \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.9.10:compile
[INFO] |  |     +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.9.10:compile
[INFO] |  |     \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.9.10:compile

EvgeniySharapov
  • 3,078
  • 3
  • 27
  • 38
  • Do you have a dependency on `io.thorntail:jaxrs-jsonb`? – Ladicek Apr 28 '20 at 15:13
  • No, I have only `microprofile`, `jsonp` and `jsonb` – EvgeniySharapov Apr 28 '20 at 15:18
  • In that case, can you try adding that? – Ladicek Apr 28 '20 at 15:28
  • I did, but i still get the same warning. I look at the dependencies jackson is still being pulled in. I updated question adding an excerpt from `dependency:tree`. I guess instead of using `microprofile` dependency i would have to list everything else but `jaxrs` from it. – EvgeniySharapov Apr 28 '20 at 15:31
  • I realized yesterday that `microprofile` actually should bring `jaxrs-jsonb` transitively, but doesn't, which is a bug (unrelated to your problem here). To be fair, I'm not sure what the problem might be. Do you perhaps have a dependency that uses Jackson annotations? – Ladicek Apr 29 '20 at 06:05

1 Answers1

2

Hope this helps someone else with a similar issue:

Just set the property to 'false' in the web.xml descriptor file of your project like this:

<context-param>
    <param-name>resteasy.preferJacksonOverJsonB</param-name>
    <param-value>false</param-value>
</context-param>
Arthur
  • 568
  • 7
  • 17