Please note that this is not an annotation issue. I saw people reading comments that, due to the @Provider annotation, did not register it, if you imported the correct provider, it will work. Please find my solution below.
I ran into the same problem when developing a sample REST API. When creating the REST API, I gave the name of the base package, for example org.manish.rest.message , I have to create all the other packages under the base package, like this
- model -
org.manish.rest.message.model - -
org.manish.rest.message.database - resource -
org.manish.rest.message.resource
in web.xml init param was specified as
<init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>org.manish.rest.message</param-value> </init-param>
This means that I registered the basic package in web.xml, some package that I will create under this; JAX-RS will be reviewed based on my requirement and requirement. But when I created my exception package in error, I put the package name org.manish.rest.exception. Since it was not registered in web.xml, so my complete exception class was not considered JAX-RS exception handling. As a correction, I just changed the name of the exception package from org.manish.rest.exception to org.manish.rest.message.exception
After that I did it once in the post man and got the expected result.
Hope this can resolve your request.
Thanks Manish
source share