jaxrs + jsonb?

192 views
Skip to first unread message

Harold Campbell

unread,
Nov 22, 2019, 12:05:17 PM11/22/19
to Thorntail
Does anyone have jaxrs + jsonb working in 2.5.0? I have in my pom:

<dependency>
<groupId>io.thorntail</groupId>
<artifactId>jaxrs</artifactId>
</dependency>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>jaxrs-jsonb</artifactId>
</dependency>

I have in a DTO:

@JsonbProperty("id")
private Long id;
@JsonbProperty("name")
private String name;
@JsonbProperty("description")
private String description;
@JsonbProperty("createdAt")
@JsonbDateFormat("yyyy-MM-ddTkk:mm:ss[.S]'Z")
private Date createdAt;
@JsonbProperty("something_else")
@JsonbDateFormat("yyyy-MM-ddTkk:mm:ss.S'Z")
private Date updatedAt;

The result, however:

[
{
"id": 1,
"name": "test node 1",
"description": "test description",
"createdAt": 1574358741845,
"updatedAt": 1574358741957
}
]

No date formatting, and the final property name is unchanged.

Is there some other bootstrapping I have to do to enable jsonb
processing?

--
Harold Campbell <hc...@muerte.net>

Ladislav Thon

unread,
Nov 25, 2019, 5:42:43 AM11/25/19
to thor...@googlegroups.com
Hi,

I'm trying this locally and it seems to work well. I didn't have to do
anything special. (Your date format string is invalid, BTW. The 'T' in
the middle needs to be escaped, and the apostrophe at the end too.)

Can you share a small standalone reproducer?

Thanks,

LT

Harold Campbell

unread,
Nov 25, 2019, 8:10:31 PM11/25/19
to Ladislav Thon, thor...@googlegroups.com
It's hard to get a date format right when it doesn't get applied at all.
;)

In the course of putting together a reproducer I figured out it's
spring-data-jpa messing things up. And working with a smaller project, I
finally spotted the tell-tale sign:

2019-11-25 18:52:00,461 WARN [org.jboss.as.jaxrs] (MSC service thread
1-2) 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.

What's annoying is I checked my effective-pom for a jackson dependency
and found none. I guess they embed jackson rather than using a
dependency. <grumble>

Reproducer attached for completeness.
> --
> You received this message because you are subscribed to the Google
> Groups "Thorntail" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to thorntail+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/thorntail/c0114eaa-16c5-598e-68be-c6bea6c5ce30%40redhat.com.

--
Harold Campbell <hc...@muerte.net>
jsonb-test.tar.gz

Ladislav Thon

unread,
Nov 26, 2019, 3:59:43 AM11/26/19
to thor...@googlegroups.com
On 26. 11. 19 2:10, Harold Campbell wrote:
> It's hard to get a date format right when it doesn't get applied at all. ;)

It's pretty well documented ;-)

> In the course of putting together a reproducer I figured out it's
> spring-data-jpa messing things up. And working with a smaller project, I
> finally spotted the tell-tale sign:
>
> 2019-11-25 18:52:00,461 WARN  [org.jboss.as.jaxrs] (MSC service thread
> 1-2) 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.
>
> What's annoying is I checked my effective-pom for a jackson dependency
> and found none. I guess they embed jackson rather than using a
> dependency. <grumble>

They don't embed Jackson, but they indeed use Jackson annotations on
some of their classes. These become part of the deployment, and you
already know the rest.

Glad you figured it out!

LT
Reply all
Reply to author
Forward
0 new messages