title: Spring Security: access-denied-handler doesn't forward to error page
body: <p>I'm fresh off the boat to Spring Security so excuse me if this seems awfully trivial..</p>
  
  <p>I try to put the Spring Security mechanism in my MVC project, but for some reason the access-denied-handler doesn't send my unauthorized user to the denied access page and instead chooses to present the login page.</p>
  
  <p>Here is my Http tag in the security-context.xml:</p>
  
  <pre><code>&lt;http authentication-manager-ref="dao-auth"
      access-decision-manager-ref="accessDecisionManager"
      disable-url-rewriting="true"&gt;
      &lt;intercept-url pattern="/pages/home.html" access="USER"&gt;&lt;/intercept-url&gt;
      &lt;intercept-url pattern="/home" method="GET" access="USER"&gt;&lt;/intercept-url&gt;
      &lt;intercept-url pattern="/logout" access="USER"&gt;&lt;/intercept-url&gt;
      &lt;intercept-url pattern="/denied" access="ROLE_ANONYMOUS"&gt;&lt;/intercept-url&gt;
      &lt;intercept-url pattern="/error" access="ROLE_ANONYMOUS,USER"&gt;&lt;/intercept-url&gt;
      &lt;intercept-url pattern="/"  access="ROLE_ANONYMOUS,USER"&gt;&lt;/intercept-url&gt;
      &lt;intercept-url pattern="/pages/**" access="ROLE_ANONYMOUS,USER"&gt;&lt;/intercept-url&gt;
      &lt;intercept-url pattern="/resources/**" access="ROLE_ANONYMOUS,USER"&gt;&lt;/intercept-url&gt;
      &lt;form-login login-page="/login" authentication-failure-url="/denied" 
          default-target-url="/home" /&gt;
      &lt;logout invalidate-session="true" logout-success-url="/"
          logout-url="/logout" /&gt;
      &lt;access-denied-handler error-page="/denied" /&gt;
      &lt;session-management invalid-session-url="/login"&gt;
          &lt;concurrency-control max-sessions="1"
              expired-url="/login" /&gt;
      &lt;/session-management&gt;
  &lt;/http&gt;
  </code></pre>
  
  <p>Basically the way I test it is I try to access the /home path from the ROLE_ANONYMOUS user and instead get thrown to the /login one.</p>
  
  <p>Also, can't figure out how to debug this thing or where I find the logs (feels like there are somewhere out there..)</p>
  
  <p>Thanks to all responders :)</p>