NoSuchMethodException org.springframework.security.web.session.ConcurrentSessionFilter。<init>()?

时间:2016-11-28 06:06:21

标签: java spring-security configuration

我正在修改spring-security从spring security-3到spring security-4.x。我按照这个链接: - enter link description here

我的配置是: -

<?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-4.2.xsd
            http://www.springframework.org/schema/security 
             http://www.springframework.org/schema/security/spring-security-4.0.xsd">

    <!-- This is where we configure Spring-Security --> 
    <security:http  entry-point-ref="loginUrlAuthenticationEntryPoint"> 
    <security:custom-filter position="CONCURRENT_SESSION_FILTER" ref="concurrencyFilter" /> 
    <security:custom-filter position="FORM_LOGIN_FILTER" ref="myAuthFilter" /> 

    <security:session-management session-authentication-strategy-ref="sas"/> 
    <security:custom-filter ref="filter" before="FILTER_SECURITY_INTERCEPTOR" /> 
    <security:logout invalidate-session="true" logout-success-url="/login"/> 

    </security:http> 

    <bean id="loginUrlAuthenticationEntryPoint"  class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint"> 
    <property name="loginFormUrl" value="/login"/> 
    </bean> 

    <bean id="concurrencyFilter" class="org.springframework.security.web.session.ConcurrentSessionFilter"> 
    <property name="sessionRegistry" ref="sessionRegistry" /> 
    <property name="expiredUrl" value="/login" /> 
    </bean> 

    <bean id="myAuthFilter" class= "org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter"> 
    <property name="sessionAuthenticationStrategy" ref="sas" /> 
    <property name="authenticationManager" ref="authenticationManager" /> 
    <property name="authenticationFailureHandler" ref="failureHandler"/> 
    <property name="authenticationSuccessHandler" ref="successHandler"/>
    </bean> 

    <bean id="sas" class= "org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy"> 
    <constructor-arg name="sessionRegistry" ref="sessionRegistry" /> 
    <property name="maximumSessions" value="1" /> 
    <property name="exceptionIfMaximumExceeded" value="true"/>
    </bean> 

    <bean id="successHandler" class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler"> 
    <property name="defaultTargetUrl" value="/home"/> 
    </bean> 

    <bean id="failureHandler" class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler"> 
    <property name="defaultFailureUrl" value="/login?failed=true"/> 
    </bean> 

    <bean id="sessionRegistry" class="org.springframework.security.core.session.SessionRegistryImpl" /> 

    <bean id="filter" class="org.springframework.security.web.access.intercept.FilterSecurityInterceptor"> 
        <property name="authenticationManager" ref="authenticationManager"/> 
        <property name="accessDecisionManager"> 
    <bean class="org.springframework.security.access.vote.AffirmativeBased"> 
        <property name="decisionVoters" > 
    <bean class="org.springframework.security.access.vote.RoleVoter"> 
        <property name="rolePrefix" value="ROLE_"/> 
    </bean> 
        </property> 
    </bean> 
        </property> 
        <property name="securityMetadataSource" ref="dbFilterInvocationSecurityMetadataSource"/> 
    </bean> 

    <!-- Authentication Manger config --> 
    <security:authentication-manager alias="authenticationManager"> 
    <security:authentication-provider user-service-ref="authenticationService"/> 
    </security:authentication-manager> 
    </beans>

我得到这样的例外: -

Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy] for bean with name 'sas' defined in ServletContext resource [/WEB-INF/springs-security.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy from [Module "deployment.CreditProcessClient.war:main" from Service Module Loader]
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy] for bean with name 'sas' defined in ServletContext resource [/WEB-INF/springs-security.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy from [Module "deployment.CreditProcessClient.war:main" from Service Module Loader]
11:15:41,175 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-6) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#0' while setting bean property 'sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'concurrencyFilter' while setting constructor argument with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'concurrencyFilter' defined in ServletContext resource [/WEB-INF/springs-security.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.session.ConcurrentSessionFilter]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.security.web.session.ConcurrentSessionFilter.<init>()
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy] for bean with name 'sas' defined in ServletContext resource [/WEB-INF/springs-security.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy from [Module org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy] for bean with name 'sas' defined in ServletContext resource [/WEB-INF/springs-security.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy from [Module java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_111]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_111]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'concurrencyFilter' while setting constructor argument with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'concurrencyFilter' defined in ServletContext resource [/WEB-INF/springs-security.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.session.ConcurrentSessionFilter]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.security.web.session.ConcurrentSessionFilter.<init>()
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:382) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:157) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:634) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:140) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    ... 26 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'concurrencyFilter' defined in ServletContext resource [/WEB-INF/springs-security.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.session.ConcurrentSessionFilter]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.security.web.session.ConcurrentSessionFilter.<init>()
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1105) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1050) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    ... 40 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.session.ConcurrentSessionFilter]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.security.web.session.ConcurrentSessionFilter.<init>()
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:85) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1098) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    ... 48 more
Caused by: java.lang.NoSuchMethodException: org.springframework.security.web.session.ConcurrentSessionFilter.<init>()
    at java.lang.Class.getConstructor0(Class.java:3082) [rt.jar:1.8.0_111]
    at java.lang.Class.getDeclaredConstructor(Class.java:2178) [rt.jar:1.8.0_111]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:80) [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    ... 49 more

11:15:41,182 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-oss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_111]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_111]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_111]
Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#0' while setting bean property 'sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'concurrencyFilter' while setting constructor argument with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'concurrencyFilter' defined in ServletContext resource [/WEB-INF/springs-security.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.session.ConcurrentSessionFilter]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.security.web.session.ConcurrentSessionFilter.<init>()
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy] for bean with name 'sas' defined in ServletContext resource [/WEB-INF/springs-security.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy from [Module "deployment.CreditProcessClient.war:main" from Service Module Loader]
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy] for bean with name 'sas' defined in ServletContext resource [/WEB-INF/springs-security.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy from [Module io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:223)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:87)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    ... 3 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#0' while setting bean property 'sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'concurrencyFilter' while setting constructor argument with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'concurrencyFilter' defined in ServletContext resource [/WEB-INF/springs-security.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.session.ConcurrentSessionFilter]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.security.web.session.ConcurrentSessionFilter.<init>()
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy] for bean with name 'sas' defined in ServletContext resource [/WEB-INF/springs-security.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy from [Module org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy] for bean with name 'sas' defined in ServletContext resource [/WEB-INF/springs-security.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy from [Module  io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:194)
    ... 7 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'concurrencyFilter' while setting constructor argument with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'concurrencyFilter' defined in ServletContext resource [/WEB-INF/springs-security.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.session.ConcurrentSessionFilter]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.security.web.session.ConcurrentSessionFilter.<init>()
    org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
    ... 26 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'concurrencyFilter' defined in ServletContext resource [/WEB-INF/springs-security.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.session.ConcurrentSessionFilter]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.security.web.session.ConcurrentSessionFilter.<init>()

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.session.ConcurrentSessionFilter]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.security.web.session.ConcurrentSessionFilter.<init>()
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:85)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1098)
    ... 48 more
Caused by: java.lang.NoSuchMethodException: org.springframework.security.web.session.ConcurrentSessionFilter.<init>()
    at java.lang.Class.getConstructor0(Class.java:3082) [rt.jar:1.8.0_111]
    at java.lang.Class.getDeclaredConstructor(Class.java:2178) [rt.jar:1.8.0_111]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:80)
    ... 49 more
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#0' while setting bean property 'sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'concurrencyFilter' while setting constructor argument with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'concurrencyFilter' defined in ServletContext resource [/WEB-INF/springs-security.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.session.ConcurrentSessionFilter]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.security.web.session.ConcurrentSessionFilter.<init>()
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy] for bean with name 'sas' defined in ServletContext resource [/WEB-INF/springs-security.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy from [Module \"deployment.CreditProcessClient.war:main\" from Service Module Loader]
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy] for bean with name 'sas' defined in ServletContext resource [/WEB-INF/springs-security.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy from [Module \"deployment.CreditProcessClient.war:main\" from Service Module Loader]
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#0' while setting bean property 'sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'concurrencyFilter' while setting constructor argument with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'concurrencyFilter' defined in ServletContext resource [/WEB-INF/springs-security.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.session.ConcurrentSessionFilter]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.security.web.session.ConcurrentSessionFilter.<init>()
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy] for bean with name 'sas' defined in ServletContext resource [/WEB-INF/springs-security.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy from [Module \"deployment.CreditProcessClient.war:main\" from Service Module Loader]
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy] for bean with name 'sas' defined in ServletContext resource [/WEB-INF/springs-security.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy from [Module \"deployment.CreditProcessClient.war:main\" from Service Module Loader]
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'concurrencyFilter' while setting constructor argument with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'concurrencyFilter' defined in ServletContext resource [/WEB-INF/springs-security.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.session.ConcurrentSessionFilter]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.security.web.session.ConcurrentSessionFilter.<init>()
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'concurrencyFilter' defined in ServletContext resource [/WEB-INF/springs-security.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.session.ConcurrentSessionFilter]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.security.web.session.ConcurrentSessionFilter.<init>()
    Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.session.ConcurrentSessionFilter]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.security.web.session.ConcurrentSessionFilter.<init>()
    Caused by: java.lang.NoSuchMethodException: org.springframework.security.web.session.ConcurrentSessionFilter.<init>()"}}

请帮我修改此配置文件中的一些更改。

2 个答案:

答案 0 :(得分:5)

<bean id="concurrencyFilter" class="org.springframework.security.web.session.ConcurrentSessionFilter"> 
  <property name="sessionRegistry" ref="sessionRegistry" /> 
  <property name="expiredUrl" value="/login" /> 
</bean> 

ConcurrentSessionFilter使用构造函数 - 参数依赖注入。改为

<bean id="concurrencyFilter" class="org.springframework.security.web.session.ConcurrentSessionFilter"> 
  <constructor-arg ref="sessionRegistry" /> 
  <constructor-arg value="/login" /> 
</bean> 

答案 1 :(得分:0)

我正在从 spring security 3.1.4 迁移到 spring security 5.2.0,但我遇到了同样的错误。

我用的是这个:

<beans:bean id="sessionAuthenticationStrategy" class="org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy">
    <beans:constructor-arg name="sessionRegistry" ref="sessionRegistry" />
    <beans:property name="exceptionIfMaximumExceeded" value="true"/>
    <beans:property name="maximumSessions" value="4"/>
</beans:bean>

但改为:

<beans:bean id="sessionAuthenticationStrategy" class="org.springframework.security.web.authentication.session.ConcurrentSessionControlAuthenticationStrategy">
    <beans:constructor-arg name="sessionRegistry" ref="sessionRegistry" />
    <beans:property name="exceptionIfMaximumExceeded" value="true"/>
    <beans:property name="maximumSessions" value="4"/>
</beans:bean>

然后它对我有用。