Markus KARG wrote:
> Hi Jersey Community,
>
> I am experimenting with JAX-RS resources implemented by means of JPA. I
> wonder how for that integration of JPA and JAX-RS goes: In a @GET
> method, do I have to check for NoResultException (and return code "404
> Not Found") on my own, or will Jersey automatically catch a
> NoResultException thrown by @GET and automatically return "404 Not
> Found" in that case?
>
No, by default such an exception will be mapped to a 500 response.
You can trap that exception in your @GET method or you can register an
exception mapper to transform that exception into a 404 response.
For example:
@Provider
public class NoResultException404
implements ExceptionMapper<NoResultException> {
public Response toResponse(NoResultException we) {
// build 404 response and return
}
}
Paul.
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109