title: Spring Security AccessDeniedException caught by @ExceptionHandler
body: <p>I have following spring-security.xml</p>
  
  <pre><code>&lt;security:global-method-security proxy-target-class="true" secured-annotations="enabled" /&gt;
  &lt;security:http auto-config="false" use-expressions="true" entry-point-ref="customLoginEndpoint" &gt;
      &lt;security:custom-filter ref="authenticationFilter" position="FORM_LOGIN_FILTER"/&gt;
  &lt;/security:http&gt;
  
  &lt;bean id="authenticationFilter" class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter"
      p:authenticationManager-ref="customAuthenticationManager"/&gt;
  </code></pre>
  
  <p>And below is customLoginEndpoint</p>
  
  <pre><code>@Component("customLoginEndpoint")
  public class CustomLoginEndpoint extends LoginUrlAuthenticationEntryPoint
  {
      public AcapLoginEndpoint()
      {
          super("/auth/login");
      }
  
      @Override
      public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authenticationException) 
              throws IOException, ServletException {
          response.sendRedirect("/auth/login");
      }   
  }
  </code></pre>
  
  <p>My controller clas has an @ExceptionHandler(Throwable ex) and few methods having @Secured annotation</p>
  
  <p>The problem is that the @ExceptionHandler method catches all org.springframework.security.access.AccessDeniedException caused by @Secured annotations and thus the request never comes to CustomLoginEndpoint.commence and gets rejected.</p>
  
  <p>If I remove @ExceptionHandler then all works well. </p>
  
  <p>How do I get this working so that commence is called and avoid @ExceptionHandler catching AccessDeniedException that are due to @Secured annotation.</p>