We are trying to get our Seam webapp to send out emails when there are unhandled exceptions. We're using the java.util.logging so we are using the smtphandler sourceforge project to allow us to configure it so that severe
level messages are sent out to a support/dev distribution list.
In order to catch those unhandled exceptions, I am trying to put in a servlet filter that just catches, logs, then rethrows the exception, like so:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
try {
chain.doFilter(request, response);
} catch (Exception e){
logger.severe(e.getMessage());
throw new ServletException(e);
}
}
Right now I'm just trying to get it to work.
The problem is that even though I configure it in the web.xml and no matter where I put it in the filter-mapping ordering, it doesn't even catch the unhandled exception (I just do a
throw new RuntimeException("Oh noooo!");
). It seems that Seam is catching the exception before me.
I tried to put in some logging into the try block and that's called. I put a break point in the catch block but it never gets called.
Anyway, I'm just wondering how to get to the exception before Seam does... Any ideas?
More info:
Seam does catch some exceptions because of the seam filter, but I'm not doing the catch-all
<exception>...</exception>
without a class attribute. So I'm just wondering why it seems to be intercepting the ones not specified in my pages.xml.