Javid Sch wrote:I use two general error-pages. But always second page (/errorPage.faces) works. What do you recommend to use for this?
The super exception class always takes over precedence, so you should not catch the java.lang.Exception. Instead, you should catch specific exceptions.
It may be because the exception that is thrown is not javax.faces.application.ViewExpiredException rather it is some subclass of Exception so always second handler comes into picture.
Haina Minawa wrote:The super exception class always takes over precedence...
Seetharaman Venkatasamy wrote:most specific match win!
I've seen both these statements, but they can't both be correct! I decided since I couldn't find a good clear answer googling, I'd try for myself. I created two Exception classes - a GenericException and a SpecificException as a subclass of the former. I then added this to my web.xml:
When I build a servlet that throws a SpecificException, the SpecificExceptionHandler.jsp is served with Tomcat 6.0. Same with Tomcat 5.5. If I reverse the entries in my web.xml, same thing - the more specific class is matched.
If that's any indicator of the spec (I hope it is), it looks like it favors the most specific exception class.
OCPJP
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
Most likely is that your ViewExpiredException is being wrapped by another exception of some description - ServletException? Thus it doesn't match on the first pass.
Basically it makes a pass through the list of handled error pages.
If it doesn't find a match, then it looks at the exception cause, and tries that for a match.
Because you have a matcher for "Exception" it stops there without looking at the cause.
If you didn't have the declaration there with java.lang.Exception, it would probably work as you were wanting it to.