JAX-RS Issue With Overridden Param Annotations
Be aware that with the Jackson JAX-RS implementation, copying @Param
annotations from the interface into the implementation cause the endpoint to be unusable.
What To Look For
If you are having trouble reaching an endpoint that appears to be configured properly, especially if other endpoints are working fine, check the interface and implementations. For example, if your JAX-RS interface is defined like this:
@Path("widget/{uuid}")
@Produces("application/json")
@GET
String getWidget(@PathParam("uuid") String uuid);
and your implementation is defined like this:
@Override
public String getWidget(@PathParam("uuid") String uuid) {
then you may be unable to access your endpoint. Re-declaring the path parameter in the implementing class confuses JAX-RS and makes the endpoint inaccessible.
The Fix
Once you know what to look for, the fix is easy. Simply remove the @Param
annotations from the implementation class:
@Override
public String getWidget(String uuid) {
Then you'll be able to successfully call the endpoint again.
Last modified on 13 Oct 2024 by AO
Copyright © 2024 Andrew Oliver