I suspect it is cause there was no exception from a service bean but just no matching so ExceptionMapper resolution is not triggered at all - which makes sense but it would have been an elegant way to solve it.
Here is a sample handler: https://github.com/apache/tomee/blob/97744bcfd33d11dbf1efd8b93c2fa32779896a6b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/notfound/CustomHandler.java#L32 and how to configure it: https://github.com/apache/tomee/blob/97744bcfd33d11dbf1efd8b93c2fa32779896a6b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/notfound/NotFoundTest.java#L40 Romain Manni-Bucau @rmannibucau <https://twitter.com/rmannibucau> | Blog <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber <http://www.tomitribe.com> | JavaEE Factory <https://javaeefactory-rmannibucau.rhcloud.com> 2016-06-06 9:28 GMT+02:00 Kirys <[email protected]>: > I don't think I'll use something different by TomEE so portability isn't > an issue. > But I would like to figure out why the ExceptionMapper doesn't work, maybe > it is something that I didn't configure properly. > > I'll try to make a demo app that reproduces the issue > > > On 05/06/2016 21:53, Romain Manni-Bucau wrote: > >> The last one should catch it otherwise a Filter wrapping the request is >> likely the easiest. If you don't care staying 100% portable a CXF >> interceptor (or another extension point) does the job pretty well AFAIK >> >> >> Romain Manni-Bucau >> @rmannibucau <https://twitter.com/rmannibucau> | Blog >> <http://rmannibucau.wordpress.com> | Github < >> https://github.com/rmannibucau> | >> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber >> <http://www.tomitribe.com> | JavaEE Factory >> <https://javaeefactory-rmannibucau.rhcloud.com> >> >> 2016-06-05 21:42 GMT+02:00 Kirys <[email protected]>: >> >> On 05/06/2016 21:20, Romain Manni-Bucau wrote: >>> >>> Did you try an ExceptionMapper? It could handle 404 and delegate others. >>>> >>>> tried these two without any result: >>> >>> @Provider >>> public class EntityNotFoundMapper >>> implements ExceptionMapper<EntityNotFoundException> { >>> >>> @Override >>> public Response toResponse(EntityNotFoundException e) { >>> return Response.status(Response.Status.NOT_FOUND).build(); >>> } >>> } >>> >>> >>> @Provider >>> public class WebApplicationExceptionHandler implements >>> ExceptionMapper<WebApplicationException> { >>> >>> @Override >>> public Response toResponse(WebApplicationException e) { >>> return Response.status(Response.Status.NOT_FOUND).build(); >>> } >>> } >>> >>> >>> >
