Announcement Announcement Module
Collapse
No announcement yet.
Problem web.xml in Spring MVC and Spring Security Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem web.xml in Spring MVC and Spring Security

    Greetings all, i am using spring security 3.1.1 in Spring MVC project in Eclipse Juno. I'm doing a basic example ( http://www.mkyong.com/spring-securit...world-example/ ).

    I'm having trouble adding Spring Security to web.xml (HTTP Status 404).


    web.xml

    Code:
    <web-app version="3.0"
             xmlns="http://java.sun.com/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
             http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
             metadata-complete="true">
    
     <display-name>Java EE 6 Starter Application</display-name>
    
      <context-param>
    	<param-name>contextConfigLocation</param-name>
    	<param-value>classpath:/META-INF/spring/applicationContext.xml,
    				classpath:/META-INF/spring/infrastructure.xml</param-value>
      </context-param>
    
      <listener>
    	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
    
      <servlet>
    	<servlet-name>jboss-as-kitchensink</servlet-name>
    	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    	<init-param>
    	  <param-name>contextConfigLocation</param-name>
    	  <param-value>/WEB-INF/jboss-as-spring-mvc-context.xml</param-value>
    	</init-param>
    	<load-on-startup>1</load-on-startup>
      </servlet>
    
      <servlet-mapping>
    	<servlet-name>jboss-as-kitchensink</servlet-name>
    	<url-pattern>/</url-pattern>
      </servlet-mapping>
      
      <!-- Spring Security -->
    	<filter>
    		<filter-name>springSecurityFilterChain</filter-name>
    		<filter-class>
                      org.springframework.web.filter.DelegatingFilterProxy
                    </filter-class>
    	</filter>
     
    	<filter-mapping>
    		<filter-name>springSecurityFilterChain</filter-name>
    		<url-pattern>/*</url-pattern>
    	</filter-mapping>
      
    </web-app>
    spring-security.xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <beans:beans xmlns="http://www.springframework.org/schema/security"
    	xmlns:beans="http://www.springframework.org/schema/beans" 
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	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.3.xsd">
     
    	<http auto-config="true">
    		<intercept-url pattern="/welcome*" access="ROLE_USER" />
    	</http>
     
    	<authentication-manager>
    	  <authentication-provider>
    	    <user-service>
    		<user name="mkyong" password="123456" authorities="ROLE_USER" />
    	    </user-service>
    	  </authentication-provider>
    	</authentication-manager>
     
    </beans:beans>
    jboss-as-spring-mvc-context.xml

    Code:
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:mvc="http://www.springframework.org/schema/mvc"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
    		http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
    
    	<context:component-scan base-package="org.fisi.app.pruebas.springsecurity.mvc"/>
    
    	<mvc:annotation-driven />
    
    	<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<property name="prefix" value="/WEB-INF/views/"/>
    		<property name="suffix" value=".jsp"/>
    	</bean>
    
    	<mvc:resources mapping="/static/**" location="/"/>
    
    	<mvc:default-servlet-handler />
    
    </beans>
    I hope you can help me, thanks.
Working...
X