How do I catch these invalid URLs so that I return a proper error resource?
Thanks.
Basically, I want to override the “The resource not found Page.” and instead I want to return an XML describing the error.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends a bit in which JAX-RS implementation you are using.
If you are using RESTEasy, you can create an
ExceptionMapperthat catchesorg.jboss.resteasy.spi.NotFoundException. That enables you to build and return a customjavax.ws.rs.core.ResponseI’m a bit unsure on how to do this with Jersey, but maybe you can create an
ExceptionMapperthat catchescom.sun.jersey.api.NotFoundException.