-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
RESTEasy tries to instantiate abstract resource base class #12927
Comments
/cc @patriot1burke @gsmet |
hmm, this will work for interfaces, but the spec does not require it to work this way for abstract classes. |
Well, I found this: https://stackoverflow.com/a/25924310/9529981 |
To resolve quoted quoting:
see https://download.oracle.com/otn-pub/jcp/jaxrs-2_0-fr-eval-spec/jsr339-jaxrs-2.0-final-spec.pdf |
May I kindly ask you @asoldano for an opinion from the RESTeasy POV? |
This is supposed to work. Quarkus is probably adding the abstract class as a resource by mistake. |
Can you post a simplified example of what triggers the problem? I want to make sure I'm testing all the scenarios. |
Even simpler than what I described under "To Reproduce"? No, sorry, not at the moment. |
Apologies!!! I need to learn to read. :) |
No worries, it happens to all of us! 😁 |
Pretty sure this is the issue: " Note that inheritance of class or interface annotations is not supported." Concrete classes must specify a @path annotation at the class level. (FYI, I was on JAX-RS 2.0 spec). @path("/foo") Quarkus is spitting out the wrong error message, but this wouldn't be supported in Resteasy anyways. |
FYI, the reason for requiring @path on the concrete class is for cases where multiple classes extended the same abstract class (or interface), IIRC. |
Interesting! I can confirm that moving But why is a "class level" PS: All this also means that openapi-generator producing class level |
Nevermind, looks like Resteasy supports that case too. Sorry, its been so long since I've had to deal with this (10years). Patch incoming. |
support abstract classes for resteasy #12927
Describe the bug
If your REST resource extends an abstract base class that contains all the typical annotations like
@Path
,@GET
etc. then you'll see this failure when invoking the resource:Such abstract base classes can be the result of https://github.com/OpenAPITools/openapi-generator
Expected behavior
Resource classes can use abstract base classes (that contain JAX-RS annotations) without problems.
Actual behavior
Invocation of such a resource fails.
To Reproduce
Steps to reproduce the behavior:
git clone https://github.com/famod/quarkus-quickstarts
git switch rest-abstract
cd getting-started
mvn clean verify
(will fail with the mentioned error)mvn clean package -DskipTests
java -jar target/getting-started-1.0-SNAPSHOT-runner.jar
curl localhost:8080/hello
(will fail with the mentioned error)Configuration
not relevant
Environment (please complete the following information):
uname -a
orver
:MINGW64_NT-10.0-18363 XXX 3.0.7-338.x86_64 2019-11-21 23:07 UTC x86_64 Msys
java -version
:OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.8+10, mixed mode)
mvnw --version
orgradlew --version
): Apache Maven 3.6.3Additional context
Interfaces do work but annotation discovery has some blind spots in that case:
The text was updated successfully, but these errors were encountered: