Results 1 to 3 of 3

Thread: Exception not seen by ExceptionHandler

  1. #1
    Join Date
    Feb 2005
    Posts
    15

    Default Exception not seen by ExceptionHandler

    Hi all.

    Im still new to the springframework and acegi.
    I have this problem. In my App I have a class that implements HandlerExceptionResolver to catch all exceptions and display the modelview what I want for different exceptions(Using ResourceBundleMessageSource). It works perfectly for all my exceptions(Database,Access denied,etc) except if the user enters a url he's not supose to view I get the 403 forbidden page. Im not sure if the FilterSecurityInterceptor throws a exception. My Exception Handler does not see any exception. Thus, I just want to specify my custom error modelview when a user enters a forbidden URL.

    I anyone can please help or put me in a direction to what I should do.
    Thanks

  2. #2
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    FilterSecurityInterceptor, if there is an AccessDeniedException in deciding whether to allow a given URI to be called, will never pass to the underlaying servlets (including HandlerExceptionResolver).

    Your easiest solution for a custom error page for 403 errors is to override this method in FilterSecurityInterceptor with a standard redirect:

    Code:
        protected void sendAccessDeniedError(FilterInvocation fi,
            AccessDeniedException accessDenied)
            throws ServletException, IOException {
            ((HttpServletRequest) fi.getRequest()).getSession().setAttribute(ACEGI_SECURITY_ACCESS_DENIED_EXCEPTION_KEY,
                accessDenied);
            ((HttpServletResponse) fi.getResponse()).sendError(HttpServletResponse.SC_FORBIDDEN,
                accessDenied.getMessage()); // 403
        }

  3. #3
    Join Date
    Feb 2005
    Posts
    15

    Default

    Thanks Ben. Were also thinking that wil be the easiest solution.

Similar Threads

  1. Replies: 3
    Last Post: Oct 5th, 2005, 08:39 AM
  2. Context initialization failed
    By kanonmicke in forum Container
    Replies: 7
    Last Post: Sep 29th, 2005, 12:35 AM
  3. Odd behaviour when injecting TransactionTemplate
    By damon311 in forum Container
    Replies: 3
    Last Post: Jul 23rd, 2005, 11:21 AM
  4. Replies: 0
    Last Post: Jul 11th, 2005, 05:49 PM
  5. Replies: 3
    Last Post: Nov 8th, 2004, 07:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •