@Path annotation not used if inherited from an interface
See original GitHub issueThe @Path
annotation is not used if it is inherited from an interface.
Example for a base interface:
@Path("/persons")
public interface PersonResource {
}
The client interface now inherits from the above one:
@RegisterRestClient(configKey = "person-service")
public interface PersonService extends PersonResource {
}
This will lead to the following (wrong) call:
http://localhost:8080/whatever
Adding a superfluous @Path
on the rest client interface makes it work correctly:
@Path("/persons")
@RegisterRestClient(configKey = "person-service")
public interface PersonService extends PersonResource {
}
This will lead to the following (correct) call:
http://localhost:8080/persons/whatever
The expected behaviour would be, that the @Path
annotation is correctly used from the parent interface and there is no need to duplicate it.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Annotation is not inherited from interface method
Inherited : Note that this meta-annotation type has no effect if the annotated type is used to annotate anything other than a class....
Read more >JAX-RS - Annotation Inheritance - LogicBig
Inheritance of class or interface annotations is not supported. That means only method level JAX-RS are inherited to the sub-classes.
Read more >JAX-RS: Path annotations from inherited interface shouldn't be ...
JAX-RS: Path annotations from inherited interface shouldn't be suggested in completion in case Path overrided in class which implement interface.
Read more >Chapter 51. Annotation Inheritance Red Hat JBoss Fuse 6.2
JAX-RS's annotation inheritance also extends to support for interfaces. Implementation classes inherit the JAX-RS annotations used in the interface they ...
Read more >Inherited (Java SE 18 & JDK 18) - Oracle Help Center
Note that this meta-annotation interface has no effect if the annotated interface is used to annotate anything other than a class.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @michael-schnell , thanks for opening this issue. We try to follow JAX-RS’s lead where possible, and in section 3.6 of the JAX-RS Spec, it talks about annotation inheritance - specifically:
So for MP Rest Client, implementations should support annotation inheritance on methods, but not on interfaces.
That said, I don’t see that this is documented in the MP Rest Client specification - and I don’t think there are any TCK tests for this. So, if you don’t mind, I’d like to keep this issue open to clarify this behavior in the spec/TCK.
Thanks again!
I am facing the same issues right now. Searching for a solution I found that annotating @Provider on the implemented class is solving the mentioned problems. What do you think about this approach, am I missing something?