title: Spring Security AOP Error
body: <p>I have created a simple spring user application. I am using Tomcat for deployment. This is my web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      id="WebApp_ID" version="2.5"&gt;
      &lt;display-name&gt;ContactSync&lt;/display-name&gt;
      &lt;filter&gt;
              &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
              &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
      &lt;/filter&gt;
  
      &lt;filter-mapping&gt;
              &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
              &lt;url-pattern&gt;/user/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;spring&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;
          /WEB-INF/spring-security.xml
          &lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;spring&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.do&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;redirect.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  
      &lt;!-- &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;default&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/static/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt; --&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>my spring-security.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:security="http://www.springframework.org/schema/security"
   xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://www.springframework.org/schema/security 
     http://www.springframework.org/schema/security/spring-security-3.0.xsd"&gt;
  
   &lt;!-- This is where we configure Spring-Security  --&gt;
   &lt;security:http auto-config="true" use-expressions="true" access-denied-page="/user/denied.do" &gt;
          &lt;security:intercept-url pattern="/" access="permitAll"/&gt;
          &lt;security:intercept-url pattern="/user/login.do" access="permitAll"/&gt;
          &lt;!-- Not using admin role right now --&gt;
          &lt;!-- &lt;security:intercept-url pattern="/user/admin" access="hasRole('ROLE_ADMIN')"/&gt; --&gt;
          &lt;security:intercept-url pattern="/user/common.do" access="hasRole('ROLE_USER')"/&gt;
  
          &lt;security:form-login
                  login-page="/user/login.do" 
                  authentication-failure-url="/user/login.do?error=true" 
                  default-target-url="/user/common.do"/&gt;
  
          &lt;security:logout 
                  invalidate-session="true" 
                  logout-success-url="/user/login.do" 
                  logout-url="/user/logout.do"/&gt;
  
  
   &lt;/security:http&gt;
  
   &lt;security:authentication-manager&gt;
    &lt;security:authentication-provider&gt;
      &lt;security:user-service&gt;
          &lt;security:user name="abcd" password="abcd" authorities="ROLE_USER" /&gt;
      &lt;/security:user-service&gt;
    &lt;/security:authentication-provider&gt;
  &lt;/security:authentication-manager&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>My LIbraries are:</p>
  
  <pre><code>antlr-2.7.6.jar
  antlr-runtime-3.0.1.jar
  commons-collections-3.1.jar
  commons-dbcp-1.4.jar
  commons-logging-1.1.1.jar
  commons-pool-1.5.6.jar
  dom4j-1.6.1.jar
  gson-2.2.1.jar
  hibernate3.jar
  hibernate-annotations-3.5.1-Final.jar
  hibernate-commons-annotations-3.2.0.Final.jar
  j2ee.jar
  javassist-3.4.GA.jar
  javax.persistence-2.0.2.jar
  jstl-1.2.jar
  jta-1.1.jar
  mysql-connector-java-5.1.5.jar
  org.springframework.asm-3.0.1.RELEASE-A.jar
  org.springframework.beans-3.0.1.RELEASE-A.jar
  org.springframework.context.support-3.0.1.RELEASE-A.jar
  org.springframework.context-3.0.1.RELEASE-A.jar
  org.springframework.core-3.0.1.RELEASE-A.jar
  org.springframework.expression-3.0.1.RELEASE-A.jar
  org.springframework.jdbc-3.0.1.RELEASE-A.jar
  org.springframework.orm-3.0.1.RELEASE-A.jar
  org.springframework.transaction-3.0.1.RELEASE-A.jar
  org.springframework.web.servlet-3.0.1.RELEASE-A.jar
  org.springframework.web-3.0.1.RELEASE-A.jar
  slf4j-api-1.5.6.jar
  slf4j-simple-1.5.6.jar
  spring-aop-3.0.1.RELEASE-sources.jar
  spring-security-acl-3.0.1.RELEASE.jar
  spring-security-acl-3.0.1.RELEASE-sources.jar
  spring-security-cas-client-3.0.1.RELEASE.jar
  spring-security-cas-client-3.0.1.RELEASE-sources.jar
  spring-security-config-3.0.1.RELEASE.jar
  spring-security-config-3.0.1.RELEASE-sources.jar
  spring-security-core-3.0.1.RELEASE.jar
  spring-security-core-3.0.1.RELEASE-sources.jar
  spring-security-ldap-3.0.1.RELEASE.jar
  spring-security-ldap-3.0.1.RELEASE-sources.jar
  spring-security-openid-3.0.1.RELEASE.jar
  spring-security-openid-3.0.1.RELEASE-sources.jar
  spring-security-samples-tutorial-3.0.1.RELEASE.war
  spring-security-samples-tutorial-3.0.1.RELEASE-sources.jar
  spring-security-taglibs-3.0.1.RELEASE.jar
  spring-security-taglibs-3.0.1.RELEASE-sources.jar
  spring-security-web-3.0.1.RELEASE.jar
  spring-security-web-3.0.1.RELEASE-sources.jar
  standard-1.1.2.jar
  yuicompressor-2.4.8pre.jar
  </code></pre>
  
  <p>I am getting 404 error when trying to access login file. However i am able to access welcome file. Can anybody help me on this.</p>
  
  <pre><code>Error:
  
  HTTP Status 404 - /Learning/WEB-INF/jsp/loginpage.jsp
  
  type Status report
  
  message /Learning/WEB-INF/jsp/loginpage.jsp
  
  description The requested resource (/Learning/WEB-INF/jsp/loginpage.jsp) is not available.
  </code></pre>
  
  <p>My LoginLogout Controller:</p>
  
  <pre><code>package com.contact.test.web;
  
  
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.ModelMap;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RequestParam;
  
  @RequestMapping("/user")
  @Controller
  public class LoginLogoutController{
  
       @RequestMapping(value = "/login.do", method = RequestMethod.GET)
       public String getLoginPage(@RequestParam(value="error", required=false) boolean error, 
         ModelMap model) {
  
        // Add an error message to the model if login is unsuccessful
        // The 'error' parameter is set to true based on the when the authentication has failed. 
        // We declared this under the authentication-failure-url attribute inside the spring-security.xml
        /* See below:
         &lt;form-login 
          login-page="/user/login" 
          authentication-failure-url="/user/login?error=true" 
          default-target-url="/user/common"/&gt;*/
  
        if (error == true) {
         // Assign an error message
         model.put("error", "You have entered an invalid username or password!");
        } else {
         model.put("error", "");
        }
        // This will resolve to /WEB-INF/jsp/loginpage.jsp
        return "loginpage";
       }
  
      /**
        * Handles and retrieves the denied JSP page. This is shown whenever a regular user
        * tries to access an admin only page.
        * 
        * @return the name of the JSP page
        */
       @RequestMapping(value = "/denied.do", method = RequestMethod.GET)
        public String getDeniedPage() {
  
        // This will resolve to /WEB-INF/jsp/deniedpage.jsp
        return "deniedpage";
       }
  }
  </code></pre>
  
  <p>Structure of project is:</p>
  
  <pre><code>/Learning/WebContent
  /Learning/WebContent/META-INF
  /Learning/WebContent/WEB-INF
  /Learning/WebContent/WEB-INF/jsp
  /Learning/WebContent/WEB-INF/jsp/adminpage.jsp
  /Learning/WebContent/WEB-INF/jsp/commonpage.jsp
  /Learning/WebContent/WEB-INF/jsp/deniedpage.jsp
  /Learning/WebContent/WEB-INF/jsp/loginpage.jsp
  /Learning/WebContent/WEB-INF/jsp/userForm.jsp
  </code></pre>