title: Spring Security 3.1 redirect to login doesn't work
body: <p>I use Spring 3.1 with Spring Mvc and Spring Security.</p>
  
  <pre><code>&lt;security:http auto-config="true" use-expressions="true" access-denied-page="/views/not-authorized.jsp"&gt;
      &lt;security:form-login login-page="/login.html" 
                           login-processing-url="/j_spring_security_check"
                           default-target-url="/main.html"
                           always-use-default-target="false"
                           authentication-failure-url="/login.html?error=true" /&gt;
  
      &lt;security:logout logout-url="/j_spring_security_logout" 
                       invalidate-session="true" 
                       logout-success-url="/login.html"/&gt;
  &lt;/security:http&gt;
  </code></pre>
  
  <p>This works OK when I try to access a secured page when I'm not logged in or my session expired but it doesn't work when I call a secured action method from a controller. I just get an ActionDenied Exception in log and that's it...</p>
  
  <p>UPDATE: I deleted the old log because of the body limitation but it's the same log... Though there is a ExceptionHandlerExceptionResolver, there is no @ExceptionHandler method... </p>
  
  <pre><code>    DEBUG 17-01-2013 12:47:50,337 - FilterChainProxy:318 - /rs/administration/team/1/list.action?_dc=1358419670168&amp;role=SUPERVISOR&amp;page=1&amp;start=0&amp;limit=10&amp;sort=username&amp;dir=ASC at position 1 of 10 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
  DEBUG 17-01-2013 12:47:50,338 - HttpSessionSecurityContextRepository:139 - HttpSession returned null object for SPRING_SECURITY_CONTEXT
  DEBUG 17-01-2013 12:47:50,338 - HttpSessionSecurityContextRepository:85 - No SecurityContext was available from the HttpSession: org.apache.catalina.session.StandardSessionFacade@63f61b14. A new one will be created.
  DEBUG 17-01-2013 12:47:50,338 - FilterChainProxy:318 - /rs/administration/team/1/list.action?_dc=1358419670168&amp;role=SUPERVISOR&amp;page=1&amp;start=0&amp;limit=10&amp;sort=username&amp;dir=ASC at position 2 of 10 in additional filter chain; firing Filter: 'LogoutFilter'
  DEBUG 17-01-2013 12:47:50,339 - FilterChainProxy:318 - /rs/administration/team/1/list.action?_dc=1358419670168&amp;role=SUPERVISOR&amp;page=1&amp;start=0&amp;limit=10&amp;sort=username&amp;dir=ASC at position 3 of 10 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter'
  DEBUG 17-01-2013 12:47:50,339 - FilterChainProxy:318 - /rs/administration/team/1/list.action?_dc=1358419670168&amp;role=SUPERVISOR&amp;page=1&amp;start=0&amp;limit=10&amp;sort=username&amp;dir=ASC at position 4 of 10 in additional filter chain; firing Filter: 'BasicAuthenticationFilter'
  DEBUG 17-01-2013 12:47:50,339 - FilterChainProxy:318 - /rs/administration/team/1/list.action?_dc=1358419670168&amp;role=SUPERVISOR&amp;page=1&amp;start=0&amp;limit=10&amp;sort=username&amp;dir=ASC at position 5 of 10 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
  DEBUG 17-01-2013 12:47:50,339 - FilterChainProxy:318 - /rs/administration/team/1/list.action?_dc=1358419670168&amp;role=SUPERVISOR&amp;page=1&amp;start=0&amp;limit=10&amp;sort=username&amp;dir=ASC at position 6 of 10 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
  DEBUG 17-01-2013 12:47:50,339 - FilterChainProxy:318 - /rs/administration/team/1/list.action?_dc=1358419670168&amp;role=SUPERVISOR&amp;page=1&amp;start=0&amp;limit=10&amp;sort=username&amp;dir=ASC at position 7 of 10 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'
  DEBUG 17-01-2013 12:47:50,340 - AnonymousAuthenticationFilter:102 - Populated SecurityContextHolder with anonymous token: 'org.springframework.security.authentication.AnonymousAuthenticationToken@6fa8dbd0: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@fffdaa08: RemoteIpAddress: 127.0.0.1; SessionId: C6A69A5A39B643C5DBE37DC225E76F49; Granted Authorities: ROLE_ANONYMOUS'
  DEBUG 17-01-2013 12:47:50,340 - FilterChainProxy:318 - /rs/administration/team/1/list.action?_dc=1358419670168&amp;role=SUPERVISOR&amp;page=1&amp;start=0&amp;limit=10&amp;sort=username&amp;dir=ASC at position 8 of 10 in additional filter chain; firing Filter: 'SessionManagementFilter'
  DEBUG 17-01-2013 12:47:50,340 - FilterChainProxy:318 - /rs/administration/team/1/list.action?_dc=1358419670168&amp;role=SUPERVISOR&amp;page=1&amp;start=0&amp;limit=10&amp;sort=username&amp;dir=ASC at position 9 of 10 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
  DEBUG 17-01-2013 12:47:50,340 - FilterChainProxy:318 - /rs/administration/team/1/list.action?_dc=1358419670168&amp;role=SUPERVISOR&amp;page=1&amp;start=0&amp;limit=10&amp;sort=username&amp;dir=ASC at position 10 of 10 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
  DEBUG 17-01-2013 12:47:50,340 - AntPathRequestMatcher:103 - Checking match of request : '/rs/administration/team/1/list.action'; against '/login.html'
  DEBUG 17-01-2013 12:47:50,341 - AntPathRequestMatcher:103 - Checking match of request : '/rs/administration/team/1/list.action'; against '/views/not-authorized.jsp'
  DEBUG 17-01-2013 12:47:50,341 - FilterSecurityInterceptor:184 - Public object - authentication not attempted
  DEBUG 17-01-2013 12:47:50,341 - FilterChainProxy:304 - /rs/administration/team/1/list.action?_dc=1358419670168&amp;role=SUPERVISOR&amp;page=1&amp;start=0&amp;limit=10&amp;sort=username&amp;dir=ASC reached end of additional filter chain; proceeding with original chain
  DEBUG 17-01-2013 12:47:50,341 - DispatcherServlet:799 - DispatcherServlet with name 'action' processing GET request for [/bpms/prestataire/rs/administration/team/1/list.action]
  DEBUG 17-01-2013 12:47:50,342 - RequestMappingHandlerMapping:211 - Looking up handler method for path /rs/administration/team/1/list.action
  DEBUG 17-01-2013 12:47:50,342 - RequestMappingHandlerMapping:218 - Returning handler method [public java.util.Map&lt;java.lang.String, ?&gt; fr.isiom.bpms.prestataire.action.controllers.administration.TeamAdministrationController.listTeams(fr.isiom.bpms.prestataire.action.model.generic.ActionListParam,fr.isiom.bpms.prestataire.action.model.administration.TeamProfile,java.security.Principal) throws java.lang.Exception]
  DEBUG 17-01-2013 12:47:50,343 - DefaultListableBeanFactory:245 - Returning cached instance of singleton bean 'teamAdministrationController'
  DEBUG 17-01-2013 12:47:50,343 - DispatcherServlet:879 - Last-Modified value for [/bpms/prestataire/rs/administration/team/1/list.action] is: -1
  DEBUG 17-01-2013 12:47:50,346 - MethodSecurityInterceptor:193 - Secure object: ReflectiveMethodInvocation: public java.util.Map fr.isiom.bpms.prestataire.action.controllers.administration.TeamAdministrationController.listTeams(fr.isiom.bpms.prestataire.action.model.generic.ActionListParam,fr.isiom.bpms.prestataire.action.model.administration.TeamProfile,java.security.Principal) throws java.lang.Exception; target is of class [fr.isiom.bpms.prestataire.action.controllers.administration.TeamAdministrationController]; Attributes: [ROLE_SUPERVISOR, ROLE_TEAM_LEADER]
  DEBUG 17-01-2013 12:47:50,346 - MethodSecurityInterceptor:298 - Previously Authenticated: org.springframework.security.authentication.AnonymousAuthenticationToken@6fa8dbd0: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@fffdaa08: RemoteIpAddress: 127.0.0.1; SessionId: C6A69A5A39B643C5DBE37DC225E76F49; Granted Authorities: ROLE_ANONYMOUS
  DEBUG 17-01-2013 12:47:50,347 - AffirmativeBased:65 - Voter: org.springframework.security.access.vote.RoleVoter@3b61c3c3, returned: -1
  DEBUG 17-01-2013 12:47:50,347 - AffirmativeBased:65 - Voter: org.springframework.security.access.vote.AuthenticatedVoter@3ca2691a, returned: 0
  DEBUG 17-01-2013 12:47:50,348 - DefaultListableBeanFactory:245 - Returning cached instance of singleton bean 'org.springframework.context.annotation.internalScheduledAnnotationProcessor'
  DEBUG 17-01-2013 12:47:50,349 - ExceptionHandlerExceptionResolver:132 - Resolving exception from handler [public java.util.Map&lt;java.lang.String, ?&gt; fr.isiom.bpms.prestataire.action.controllers.administration.TeamAdministrationController.listTeams(fr.isiom.bpms.prestataire.action.model.generic.ActionListParam,fr.isiom.bpms.prestataire.action.model.administration.TeamProfile,java.security.Principal) throws java.lang.Exception]: org.springframework.security.access.AccessDeniedException: Access is denied
  DEBUG 17-01-2013 12:47:50,353 - ResponseStatusExceptionResolver:132 - Resolving exception from handler [public java.util.Map&lt;java.lang.String, ?&gt; fr.isiom.bpms.prestataire.action.controllers.administration.TeamAdministrationController.listTeams(fr.isiom.bpms.prestataire.action.model.generic.ActionListParam,fr.isiom.bpms.prestataire.action.model.administration.TeamProfile,java.security.Principal) throws java.lang.Exception]: org.springframework.security.access.AccessDeniedException: Access is denied
  DEBUG 17-01-2013 12:47:50,354 - DefaultHandlerExceptionResolver:132 - Resolving exception from handler [public java.util.Map&lt;java.lang.String, ?&gt; fr.isiom.bpms.prestataire.action.controllers.administration.TeamAdministrationController.listTeams(fr.isiom.bpms.prestataire.action.model.generic.ActionListParam,fr.isiom.bpms.prestataire.action.model.administration.TeamProfile,java.security.Principal) throws java.lang.Exception]: org.springframework.security.access.AccessDeniedException: Access is denied
  DEBUG 17-01-2013 12:47:50,356 - DispatcherServlet:910 - Could not complete request
  org.springframework.security.access.AccessDeniedException: Access is denied
      at org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:83)
      at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:205)
      at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:59)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:212)
      at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
      at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
      at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
      at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
      at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
      at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
      at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
      at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
      at java.lang.Thread.run(Thread.java:662)
  DEBUG 17-01-2013 12:47:50,360 - ExceptionTranslationFilter:165 - Access is denied (user is anonymous); redirecting to authentication entry point
  org.springframework.security.access.AccessDeniedException: Access is denied
      at org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:83)
      at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:205)
      at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:59)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:212)
      at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
      at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
      at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
      at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
      at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
      at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
      at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
      at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
      at java.lang.Thread.run(Thread.java:662)
  DEBUG 17-01-2013 12:47:50,363 - HttpSessionRequestCache:41 - DefaultSavedRequest added to Session: DefaultSavedRequest[http://localhost:8080/bpms/prestataire/rs/administration/team/1/list.action?_dc=1358419670168&amp;role=SUPERVISOR&amp;page=1&amp;start=0&amp;limit=10&amp;sort=username&amp;dir=ASC]
  DEBUG 17-01-2013 12:47:50,363 - ExceptionTranslationFilter:185 - Calling Authentication entry point.
  DEBUG 17-01-2013 12:47:50,365 - DefaultRedirectStrategy:36 - Redirecting to 'http://localhost:8080/bpms/prestataire/login.html'
  DEBUG 17-01-2013 12:47:50,366 - HttpSessionSecurityContextRepository:269 - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
  DEBUG 17-01-2013 12:47:50,366 - SecurityContextPersistenceFilter:97 - SecurityContextHolder now cleared, as request processing completed
  DEBUG 17-01-2013 12:47:50,378 - FilterChainProxy:318 - /login.html at position 1 of 10 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
  DEBUG 17-01-2013 12:47:50,378 - HttpSessionSecurityContextRepository:139 - HttpSession returned null object for SPRING_SECURITY_CONTEXT
  DEBUG 17-01-2013 12:47:50,378 - HttpSessionSecurityContextRepository:85 - No SecurityContext was available from the HttpSession: org.apache.catalina.session.StandardSessionFacade@63f61b14. A new one will be created.
  DEBUG 17-01-2013 12:47:50,378 - FilterChainProxy:318 - /login.html at position 2 of 10 in additional filter chain; firing Filter: 'LogoutFilter'
  DEBUG 17-01-2013 12:47:50,379 - FilterChainProxy:318 - /login.html at position 3 of 10 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter'
  DEBUG 17-01-2013 12:47:50,379 - FilterChainProxy:318 - /login.html at position 4 of 10 in additional filter chain; firing Filter: 'BasicAuthenticationFilter'
  DEBUG 17-01-2013 12:47:50,379 - FilterChainProxy:318 - /login.html at position 5 of 10 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
  DEBUG 17-01-2013 12:47:50,379 - DefaultSavedRequest:309 - pathInfo: both null (property equals)
  DEBUG 17-01-2013 12:47:50,379 - DefaultSavedRequest:317 - queryString: arg1=_dc=1358419670168&amp;role=SUPERVISOR&amp;page=1&amp;start=0&amp;limit=10&amp;sort=username&amp;dir=ASC; arg2=null (property not equals)
  DEBUG 17-01-2013 12:47:50,379 - HttpSessionRequestCache:75 - saved request doesn't match
  DEBUG 17-01-2013 12:47:50,380 - FilterChainProxy:318 - /login.html at position 6 of 10 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
  DEBUG 17-01-2013 12:47:50,380 - FilterChainProxy:318 - /login.html at position 7 of 10 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'
  DEBUG 17-01-2013 12:47:50,380 - AnonymousAuthenticationFilter:102 - Populated SecurityContextHolder with anonymous token: 'org.springframework.security.authentication.AnonymousAuthenticationToken@6fa8dbd0: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@fffdaa08: RemoteIpAddress: 127.0.0.1; SessionId: C6A69A5A39B643C5DBE37DC225E76F49; Granted Authorities: ROLE_ANONYMOUS'
  DEBUG 17-01-2013 12:47:50,380 - FilterChainProxy:318 - /login.html at position 8 of 10 in additional filter chain; firing Filter: 'SessionManagementFilter'
  DEBUG 17-01-2013 12:47:50,381 - FilterChainProxy:318 - /login.html at position 9 of 10 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
  DEBUG 17-01-2013 12:47:50,381 - FilterChainProxy:318 - /login.html at position 10 of 10 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
  </code></pre>
  
  <p>This is the same log as before... I commented the @ExceptionHandler method, then restarted server... Anyway this is my exceptionHandler method: </p>
  
  <pre><code>    @ExceptionHandler(RuntimeException.class)
      public ModelAndView handleException(Exception ex, HttpServletRequest request, HttpServletResponse response) {
          return getErrorResponseMap(StringUtils.EMPTY, JsonErrorCause.TECHNICAL_ERROR));
      }
      protected static Map&lt;String, Object&gt; getErrorResponseMap(String msg, String causeCode) {
  
          Map&lt;String, Object&gt; modelMap = new HashMap&lt;String, Object&gt;(ERROR_PROPERTY_COUNT);
          modelMap.put(JsonProperties.MESSAGE, msg);
          modelMap.put(JsonProperties.SUCCESS, Boolean.FALSE);
          modelMap.put(JsonProperties.CAUSE, causeCode);
  
          return modelMap;
      }
  </code></pre>
  
  <p>I even tried something like...</p>
  
  <pre><code>@ExceptionHandler(RuntimeException.class)
  public ModelAndView handleException(Exception ex, HttpServletRequest request, HttpServletResponse response) {
      ModelAndView modelAndView = new ModelAndView();
      if (ex.getMessage().contains("Access is denied")) {
          modelAndView.setViewName("/views/not-authorized.jsp");
          return modelAndView;
      }
      modelAndView.addAllObjects(getErrorResponseMap(StringUtils.EMPTY, JsonErrorCause.TECHNICAL_ERROR));
      return modelAndView;
  }
  </code></pre>
  
  <p>UPDATE 2: My showLoginPage method: </p>
  
  <pre><code>@RequestMapping(value = PageAddress.LOGIN_URL)
  public ModelAndView showLoginPage(@RequestParam(value = "error", required = false) boolean errorParam, ModelMap model) {
  
      Authentication auth = SecurityContextHolder.getContext().getAuthentication();
  
      if (!auth.getAuthorities().contains(new SimpleGrantedAuthority(ContractorRole.USER))) {
          model.put(ERROR_PROP_NAME, errorParam);
          return new ModelAndView(PageCode.LOGIN, model);
      } else {
          RedirectView mainRedirectView = new RedirectView(PageAddress.MAIN_URL, true);
          mainRedirectView.setExposeModelAttributes(false);
          return new ModelAndView(mainRedirectView);
      }
  }
  </code></pre>