hi ,i am learn Spring Security3.1.0.rc3 .when i Integrated with Struts2.2.3 and access with address
http://zhouxq/frameWork/index
there hava Struts Problem :
PHP Code:
Struts Problem Report
Struts has detected an unhandled exception:
Messages: Cannot convert value of type [org.springframework.security.web.DefaultSecurityFilterChain] to required type [java.lang.String] for property 'fieldErrors[org.springframework.security.filterChains][0]': no matching editors or conversion strategy found
Failed to convert property value of type 'java.util.LinkedHashMap' to required type 'java.util.Map' for property 'fieldErrors'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.security.web.DefaultSecurityFilterChain] to required type [java.lang.String] for property 'fieldErrors[org.springframework.security.filterChains][0]': no matching editors or conversion strategy found
Unable to instantiate Action, com.sayablog.createEngine.action.CreateAtion, defined for 'index' in namespace '/'Failed to convert property value of type 'java.util.LinkedHashMap' to required type 'java.util.Map' for property 'fieldErrors'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.security.web.DefaultSecurityFilterChain] to required type [java.lang.String] for property 'fieldErrors[org.springframework.security.filterChains][0]': no matching editors or conversion strategy found
File: jar:file:/C:/Tomcat%206.0/webapps/frameWork/WEB-INF/lib/org.springframework.beans-sources-3.0.4.RELEASE.jar!/org/springframework/beans/TypeConverterDelegate.java
Line number: 231
--------------------------------------------------------------------------------
else {
msg.append(": no matching editors or conversion strategy found");
throw new IllegalStateException(msg.toString());
}
}
i had debug it lots of time .
and this is the web.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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_2_5.xsd">
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Spring -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:applicationContext.xml,
classpath:applicationContext-security.xml
</param-value>
</context-param>
<!-- spring filter -->
<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>
<listener>
<listener-class>
org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>
<!-- Struts2 -->
<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>
and this is spring security configration
applicationContext-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.1.xsd">
<debug/>
<http pattern="/js/**" security="none"/>
<http pattern="/themes/**" security="none"/>
<http pattern="/login.jsp" security="none"/>
<http pattern="/index" security="none"/>
<http use-expressions="true" entry-point-ref="authenticationProcessingFilterEntryPoint" access-denied-page="/403.jsp">
<!--<form-login login-page="/login.jsp"
authentication-failure-url="/login.jsp?error=true"
default-target-url="/" />
-->
<!-- 实现免登陆验证 -->
<remember-me data-source-ref="dataSource" />
<session-management invalid-session-url="/timeout.jsp">
<concurrency-control max-sessions="1" error-if-maximum-exceeded="true" />
</session-management>
<!--
<logout invalidate-session="true" logout-url="/j_spring_security_logout" success-handler-ref="casLogoutSuccessHandler"/>
3.1登出清空session cookies -->
<custom-filter ref="loginFilter" position="FORM_LOGIN_FILTER" />
<custom-filter ref="securityFilter" before="FILTER_SECURITY_INTERCEPTOR"/>
</http>
<!-- 登录验证器 -->
<beans:bean id="loginFilter" class="com.sayablog.security.MyUsernamePasswordAuthenticationFilter">
<!-- 处理登录 -->
<beans:property name="filterProcessesUrl" value="/j_spring_security_check"></beans:property>
<beans:property name="authenticationSuccessHandler" ref="loginLogAuthenticationSuccessHandler"/>
<beans:property name="authenticationFailureHandler" ref="simpleUrlAuthenticationFailureHandler"/>
<beans:property name="authenticationManager" ref="myAuthenticationManager"/>
<beans:property name="usersDao" ref="usersDao"/>
</beans:bean>
<beans:bean id="loginLogAuthenticationSuccessHandler"
class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
<beans:property name="defaultTargetUrl" value="/index.jsp"/>
</beans:bean>
<beans:bean id="simpleUrlAuthenticationFailureHandler"
class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
<beans:property name="defaultFailureUrl" value="/login.jsp?error=true"/>
</beans:bean>
<!-- 认证过滤器-->
<beans:bean id="securityFilter" class="com.sayablog.security.MySecurityFilter">
<!-- 用户拥有的权限-->
<beans:property name="authenticationManager" ref="myAuthenticationManager" />
<!-- 用户是否拥有所请求资源的权限-->
<beans:property name="accessDecisionManager" ref="myAccessDecisionManager" />
<!-- 资源与权限对应关系-->
<beans:property name="securityMetadataSource" ref="mySecurityMetadataSource" />
</beans:bean>
<!-- 实现了UserDetailsService的Bean -->
<authentication-manager alias="myAuthenticationManager">
<authentication-provider user-service-ref="myUserDetailServiceImpl" />
</authentication-manager>
<!---->
<beans:bean id="myAccessDecisionManager" class="com.sayablog.security.MyAccessDecisionManager"/>
<beans:bean id="mySecurityMetadataSource" class="com.sayablog.security.MySecurityMetadataSource">
<beans:constructor-arg name="resourcesDao" ref="resourcesDao"/>
</beans:bean>
<beans:bean id="myUserDetailServiceImpl" class="com.sayablog.security.MyUserDetailServiceImpl">
<beans:property name="usersDao" ref="usersDao"/>
</beans:bean>
<!-- 未登录的切入点-->
<beans:bean id="authenticationProcessingFilterEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
<beans:property name="loginFormUrl" value="/login.jsp"/>
</beans:bean>
</beans:beans>
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:orcl" />
<property name="username" value="scott" />
<property name="password" value="tiger" />
</bean>
<!-- =========================================Sys Start============================================================ -->
<bean id="usersDao" class="com.sayablog.security.dao.impl.UsersDaoImpl">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="resourcesDao" class="com.sayablog.security.dao.impl.ResourcesDaoImpl">
<property name="dataSource" ref="dataSource"/>
</bean>
</beans>
Struts.xml
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant name="struts.objectFactory.spring.autoWire" value="type" />
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.objectFactory" value="spring" />
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default">
<global-results>
<result name="error">/error.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error"/>
</global-exception-mappings>
<action name="index" method="execute" class="com.sayablog.createEngine.action.CreateAtion">
<result type="dispatcher" name="success">/jsp/a.jsp</result>
</action>
</package>
</struts>
when i access with /jsp/a.jsp hava no problem.
i have tryed times .someone who could help me please!!thanks!