Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting noSuchMethodException on native build resteasy reactive server using reactive client #21133

Closed
manofthepeace opened this issue Nov 1, 2021 · 11 comments
Labels
area/native-image area/rest kind/bug Something isn't working triage/invalid This doesn't seem right

Comments

@manofthepeace
Copy link
Contributor

manofthepeace commented Nov 1, 2021

Describe the bug

Hi,

I am new to quarkus, I have a pretty good java/spring background. I just started a Quarkus project and I have a really simple error. I am pretty sure the issue is me being novice but I cannot figure it out.

Generated a project using quarkus 2.4.0 final, using the following extensions;

quarkus-resteasy-reactive
quarkus-rest-client-reactive-jackson
quarkus-smallrye-health
quarkus-quartz

When I use quartz scheduler, to go to my "rest-client" everything works fine (I log the response). Same thing using quarkus:dev. Basically I changed the GreetingResource to the following;

@Path("/test")
public class HttpController {

    @RestClient
    StreamService streamService;

    @GET
    @Path("/hello")
    @Produces(MediaType.APPLICATION_JSON)
    public Uni<Stream> testCall() {
        return streamService.getStreams();
    }
}

StreamService being just a stub which returns a json object that I receive as a pojo Stream object with Jackson

When I do a curl to /test/hello I do see my json come back properly with running with quarkus:dev

When I do the same curl on the natively compiled application with graalVm 21.3.0 I get ERROR [org.jbo.res.rea.com.cor.AbstractResteasyReactiveContext] (vert.x-eventloop-thread-0) Request failed: java.lang.RuntimeException: java.lang.NoSuchMethodException: org.company.HttpController.testCall()

Expected behavior

method in HttpController should be found when testing native image, and response should be returned (as does the jar does)

Actual behavior

getting NoSuchMethodException instead of getting a response back

How to Reproduce?

https://github.com/manofthepeace/quarkus-reproducer-21133

Steps to reproduce;
1- mvn quarkus:dev on the stub and exception project
2- send curl to /hello (get back json)
3- mvn clean package -Pnative on exception project
4- run the native app
5- send curl to /hello (get RuntimeException)

Output of uname -a or ver

Darwin MBP 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64

Output of java -version

openjdk version "11.0.13" 2021-10-19 OpenJDK Runtime Environment Temurin-11.0.13+8 (build 11.0.13+8) OpenJDK 64-Bit Server VM Temurin-11.0.13+8 (build 11.0.13+8, mixed mode)

GraalVM version (if different from Java)

21.3.0

Quarkus version or git rev

2.4.0.FInal

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

Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)

Additional information

No response

@manofthepeace manofthepeace added the kind/bug Something isn't working label Nov 1, 2021
@quarkus-bot quarkus-bot bot added the area/rest label Nov 1, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Nov 1, 2021

/cc @FroMage, @geoand, @stuartwdouglas

@stuartwdouglas
Copy link
Member

A reproducer would be really helpful here.

@DmitryErmolchik
Copy link

@manofthepeace I faced absolutely the same problem.
My solution is to add annotation @RegisterForReflection to the class.
But I'm baffled why NativeImageTest didn't catch this problem.

@manofthepeace
Copy link
Contributor Author

I did solve the problem by trying few different thing. I have added a reproducer here in case (follow readme if used);
https://github.com/manofthepeace/quarkus-reproducer-21133

So what fixed it for me was not @RegisterForReflection oddly enough the jackson class, works without it, natively. Was working fine when triggered via quartz scheduler.

What made it work is changing the pom dependency from quarkus-resteasy-reactive to quarkus-resteasy-reactive-jackson. It kind of make sense in a way, since I am returning and object to be serialized, but I find it really odd that it works fine when running the jar, but throws a NoSuchMethodException while running the native app. Like how come the jar is able to serialize the object without the -jackson dependency is not clear to me.

@geoand
Copy link
Contributor

geoand commented Nov 2, 2021

As Stuart said, attaching a small project that exhibits this behavior would be a tremendous help for us

@geoand geoand added the triage/needs-reproducer We are waiting for a reproducer. label Nov 2, 2021
@manofthepeace
Copy link
Contributor Author

@geoand I have linked a github repo for a reproducer in the last comment. I have now edited the first post to reflect it. https://github.com/manofthepeace/quarkus-reproducer-21133
Please advise if you need anything else.

@geoand geoand removed the triage/needs-reproducer We are waiting for a reproducer. label Nov 2, 2021
@geoand
Copy link
Contributor

geoand commented Nov 2, 2021

If you use quarkus-resteasy-reactive-jackson (which should be used when serialization / deserialization is needed for the server part), the problem goes away.

@geoand geoand closed this as completed Nov 2, 2021
@geoand geoand added triage/invalid This doesn't seem right area/native-image labels Nov 2, 2021
@manofthepeace
Copy link
Contributor Author

@geoand thanks for the reply and your time. That is indeed my finding/reproducer. I find it still odd, that the jar version works without it, but the native one throws a NoMethodException. But if that's normal behaviour, so be it!. Thanks again.

@geoand
Copy link
Contributor

geoand commented Nov 2, 2021

It's expected if you don't use the "blessed" dependencies.

@elrob
Copy link

elrob commented Jan 24, 2022

I hit the same issue. Same solution.
quarkus-resteasy-reactive works fine in JVM mode but native mode required switching to quarkus-resteasy-reactive-jackson

@DmitryErmolchik
Copy link

@elrob Hi,
You need to use the right combination of Quarkus modules:
<dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-resteasy-reactive-jackson</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-rest-client-reactive-jackson</artifactId> </dependency>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/native-image area/rest kind/bug Something isn't working triage/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

5 participants