Hello everybody. (Sorry for my english)
Im trying to get a architecture with Spring 3 + Spring Security 3 + Struts2 + Hibernate 3.
The app go right with Spring 3 + Struts2 + Hibernate 3 but I can not get anything with Spring Security.
None error is throwed by app.
Login.action and the following
JSP load fine but when I push over submit button (j_spring_security_check), nothing happend and the default action PaginaNoEncontrada (Page not Found) is loaded
¿Why does it work?
Thanks in advance.
That is my configuration code:
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<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">
<display-name>cv</display-name>
<!--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>
<!--SPRING SECURITY-->
<!--SPRING-->
<listener>
<listener-class >org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/applicationContext-dao.xml
/WEB-INF/spring/applicationContext-transaction.xml
/WEB-INF/spring/applicationContext-service.xml
<!--Spring Security Context-->
/WEB-INF/spring/applicationContext-security.xml
</param-value>
</context-param>
<!--SPRING-->
<!--STRUTS 2-->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--STRUTS 2-->
<!--TILES-->
<listener>
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
<context-param>
<param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/tiles/tiles-def.xml,/WEB-INF/tiles/tiles-def-acciones.xml</param-value>
</context-param>
<!--TILES-->
<!--WEB-LISTENER-->
<listener>
<listener-class>es.cv.comun.listeners.LoadProperties</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<error-page>
<error-code>403</error-code>
<location>/error.html</location>
</error-page>
</web-app>
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE
struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.i18n.encoding" value="UTF-8"/>
<constant name="struts.custom.i18n.resources" value="global.application, global.errores" />
<include file="example.xml"/>
<package name="default" namespace="/" extends="struts-default">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<!--INTERCEPTORS-->
<interceptors>
<interceptor name="noAction" class="es.cv.comun.interceptor.noActionInterceptor" />
<interceptor-stack name="loggingStack">
<interceptor-ref name="noAction" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="loggingStack"></default-interceptor-ref>
<!--DEFAULT-ACTION-->
<default-action-ref name="PaginaNoEncontrada" />
<!--GLOBAL RESULT-->
<global-results>
<result name="errorGeneral" type="tiles">errorGeneral</result>
</global-results>
<!--EXCEPTIONS-->
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error.errorGeneral"/>
<exception-mapping exception="java.lang.RuntimeException" result="error.errorGeneral"/>
<exception-mapping exception="comun.exceptions.AppException" result="error.errorGeneral"/>
<exception-mapping exception="comun.exceptions.BadArgumentException" result="error.errorGeneral"/>
<exception-mapping exception="comun.exceptions.FileException" result="error.errorGeneral"/>
<exception-mapping exception="comun.exceptions.SystemException" result="error.errorGeneral"/>
</global-exception-mappings>
<!--ACTIONS-->
<action name="PaginaNoEncontrada">
<result type="tiles">paginaNoEncontrada</result>
</action>
<action name="Login" class="es.cv.Login">
<result name="input">/jsp/pages/Login.jsp</result>
<result name="languaje">/jsp/pages/Login.jsp</result>
</action>
</package>
</struts>
applicationContext-security.xml
<?xml version="1.0" encoding="UTF-8"?>
<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">
<security:http auto-config="true" use-expressions="true" access-denied-page="/cv/denied.jsp" >
<security:intercept-url pattern="/cv/*" access="permitAll"/>
<security:intercept-url pattern="/cv/css/*" access="permitAll"/>
<security:intercept-url pattern="/cv/js/*" access="permitAll"/>
<security:intercept-url pattern="/cv/img/*" access="permitAll"/>
<security:intercept-url pattern="/cv/jsp/*" access="permitAll"/>
<security:intercept-url pattern="/cv/Login.action" filters="none"/>
<security:intercept-url pattern="/cv/example/*" access="isFullyAuthenticated()"/>
<security:form-login
login-page="/cv/Login.action"
default-target-url="/cv/example/HelloWorld.action"
authentication-failure-url="/cv/Login.action?error=true"/>
<security:logout
invalidate-session="true"
logout-success-url="/cv/Login.action"
logout-url="/cv/Login.action"/>
</security:http>
<bean class="org.springframework.security.authentication.encoding.Md5PasswordEncoder" id="passwordEncoder"/>
<bean id="customUserDetailsService" class="es.cv.business.services.impl.SpringSecurityService"/>
<security:authentication-manager>
<security:authentication-provider user-service-ref="customUserDetailsService">
<security:password-encoder ref="passwordEncoder"/>
</security:authentication-provider>
</security:authentication-manager>
</beans>
login.jsp
<%@include file="/jsp/meta/meta.jsp"%>
<html>
<head>
<title>Sign On</title>
</head>
<body>
<s:form action="j_spring_security_check" method="post">
<s:textfield key="j_username"/>
<s:password key="j_password" />
<s:submit key="entrar"/>
</s:form>
</body>
</html>