quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.53k stars 2.61k forks source link

Jakarta - EE 10 - RestAssured not supporting JSON-B 3.0 #29225

Open agoncal opened 1 year ago

agoncal commented 1 year ago

Describe the bug

With Quarkus 3.0.0.Alpha1, when we use the ObjectMapperType.JSONB in a RestAssured test, we get a NoClassDefFoundError because it looks for the old javax/json/bind/Jsonb package and not the new one jakarta/json/bind.

    given()
      .body(customer, ObjectMapperType.JSONB)
      .header(CONTENT_TYPE, APPLICATION_JSON)
      .header(ACCEPT, APPLICATION_JSON).
    when()
      .post("/customers").
    then()
      .statusCode(201);

RestAssured 5.2.0 still does not support it. See: https://github.com/rest-assured/rest-assured/issues/1651

Relates to https://github.com/quarkusio/quarkus/issues/13459

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

3.0.0.Alpha1

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

quarkus-bot[bot] commented 1 year ago

/cc @gsmet, @manovotn, @maxandersen, @radcortez, @sanne

gsmet commented 1 year ago

Yeah. We will have to live with it until REST Assured provides a Jakarta-compatible version.

I will document it but I think we can close it. We will update REST Assured when available.

maxandersen commented 1 year ago

@gsmet if we close these is there another way to find list of dependencies/blockers we have identified thus far that are still open?

gsmet commented 1 year ago

Not really. Let's keep it open then. I wouldn't call it a blocker really but yeah better have it in mind.

geoand commented 1 year ago

Is this still an issue?

gsmet commented 1 year ago

AFAIK, yes.

geoand commented 1 year ago

kk, thanks

agoncal commented 1 year ago

Yes, still happening in Quarkus 3 Alpha 2 as nothing has changed on the RestAssured side

gsmet commented 1 year ago

I started working on that upstream and I will see if I can come up with an acceptable solution.

konradrenner commented 1 year ago

possible workaround which I tested: using quarkus-resteasy-reactive-jackson instead of quarkus-resteasy-reactive-jsonb (the jackson plugin can handle jsonb annotations).

But it would be nice if the jsonb plugin is working again with restassured, because otherwise it can quickly happen that a mixture of jackson and jsonb annotations is used in an application.

gian1200 commented 1 year ago

What is the impact of implementing that workaround? Does it means that quarkus-resteasy-reactive-jackson is importing jsonb annotations? Is that supposed to happen?

erik-wramner commented 1 year ago

We have a fairly large amount of JSON-B adapters and really need the tests to use JSON-B, which I solved in https://github.com/quarkusio/quarkus/issues/13459#issuecomment-1274494346. Now, when we are upgrading to 3.2, this hits us hard. I would be fairly uncomfortable running a different JSON library in test than in the released version and we originally switched from Jackson to JSON-B because Jackson lacked features we need.

Any idea how we can fix or work around this? I might help with coding if needed, though I have no experience with the Quarkus code base.

gian1200 commented 1 year ago

I believe the change should be done in RestAssured (https://github.com/rest-assured/rest-assured/issues/1651)

Not sure if it's only to update the import references, or if there is anything else that should be done. I tried to contribute, but wasn't able to compile the project (I'm not versed on Groovy) and couldn't give much time to solve my environment issue.

gsmet commented 1 year ago

It’s more complex than that. I have a branch somewhere with some preliminary work but didn’t have time to finish it yet.

erik-wramner commented 1 year ago

Right. I think we will pick a few tests and rewrite them without RestAssured to see if we can get them to work and how much effort it takes.

gian1200 commented 11 months ago

Given that Quarkus 2.x EoL is going to be soon (this year as far as I've read), is there any official/recommended action to take when migrating to Quarkus 3.0?

hakdogan commented 10 months ago

As far as I understand this is still an issue for version 3.4.3 because in my test case, I am getting the error.

SaddexProductions commented 10 months ago

Given that Quarkus 2.x EoL is going to be soon (this year as far as I've read), is there any official/recommended action to take when migrating to Quarkus 3.0?

This is a major blocker for my team since all our RestAssured-tests use JSON-B. We have so far resisted to migrate to Quarkus 3 because of this, and I dread when we will have to do anyway. If this can't be fixed, I would also request a migration guide in this case.

gastaldi commented 10 months ago

This issue depends on:

marufmax commented 7 months ago

+1 having the same issue

gian1200 commented 7 months ago

Question:

Given that JSONB is still not supported, is this a valid workaround with Jackson?

  1. Update to Quarkus 3 with recommended command
  2. In pom.xml, replace all ...-jsonb with ...-jackson (e.g. quarkus-resteasy-reactive-jsonb to quarkus-resteasy-reactive-jackson)
  3. In the tests, replace ObjectMapperType.JSONB with ObjectMapperType.JACKSON_2
  4. (Optional) Replace jsonb annotations (JsonbTransient, JsonbProperty, JsonbDateFormat) with Jacksons (JsonbTransient, JsonbProperty, JsonFormat)
  5. (Optional) Update any custom JSONB code

Should I consider something else?

What's the difference between JACKSON_1 and JACKSON_2?