I may have run into a situation where exception mapping won't work in the context of using
servlet filters. I'm attempting to use a combination of a DelegatingFilterProxy and the spring security components to enforce security over my web application. The problem I've run into is that I'm using the RequestHeaderPreAuthenticatedProcessingFilter to pull a header variable out of the request header as it's designed to do.
Also, as it's designed to do, it will throw an exception if the specified header is not found. I'd like to intercept that exeption and display a better page than a stack trace. Using the ExceptionResolver, I can't seem to intercept the exception at all. I think that's because this only configures the DispatcherServlet and the filter sits in front of that since I can't see any evidence of the dispatcher in the stack trace and as I'm debugging.
Anyone have an idea how to intercept the exceptions when they come from a filter? I've even tried configuring an entry in the web.xml file using the error page definition. At least it seems to intercept it but appears to fail in trying to serve up the page (not sure why since I can't get any additional information). My page is simply '/error.html'. I can get to the resource if I simply put it on the URL path but no luck during invocation of the filter. I've boiled it down to be as simple as possible. That should catch any exception of type java.lang.Exception, which does appear to happen. I must be missing something because this just seems like it should work... unless there's something going on with
Tomcat (v6).
Thanks,
mark