我正在尝试通过连接到 LDAP 使用 Spring Security 进行我的第一个演示。
我使用的Sping版本是:3.1.0.RELEASE
这是我的security-integration.xml:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:security="http://www.springframework.org/schema/security"
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.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:com/demo/spring/security.properties</value>
</list>
</property> </bean>
<security:http auto-config='false' access-denied-page="/accessDenied" use-expressions="true">
<!--I've removed login."htm"?error=true-->
<security:form-login
login-page="/login"
authentication-failure-url="/login?error=true"
login-processing-url="/loginProcess"
default-target-url="/home"/>
<!--<security:logout-->
<!--invalidate-session="true"-->
<!--logout-success-url="/login"-->
<!--logout-url="/logout"/>-->
</security:http>
<bean id="contextSource"
class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
<constructor-arg value="${securityContextSource.url}"/>
<property name="userDn" value="${securityContextSource.userDn}"/>
<property name="password" value="${securityContextSource.password}"/> </bean>
<bean id="userSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
<constructor-arg index="0" value="${filterBasedLdapUserSearch.searchBase}"/>
<constructor-arg index="1" value="${filterBasedLdapUserSearch.searchFilter}"/>
<constructor-arg index="2" ref="contextSource"/> </bean>
<bean id="bindAuthenticator" class="org.springframework.security.ldap.authentication.BindAuthenticator">
<constructor-arg ref="contextSource"/>
<property name="userSearch" ref="userSearch"/> </bean>
<bean id="ldapAuthProvider"
class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
<constructor-arg ref="bindAuthenticator"/>
</bean>
<security:authentication-manager>
<security:authentication-provider ref="ldapAuthProvider"/>
</security:authentication-manager>
</beans>
但是,每当我部署我的战争时,我都会遇到这个异常:
HTTP 状态 500 -
类型异常报告
信息
描述 服务器遇到一个内部错误 () 阻止它完成这个请求。
例外
javax.servlet.ServletException:servlet spring 的 Servlet.init() 抛出异常 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java: 98) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) org.apache.coyote.http11.AbstractHttp11Processor.process( AbstractHttp11Processor.java:987) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579) org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307) java.util. concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) java.lang.Thread.run(Thread.java:619) 根本原因
org.springframework.beans.factory.BeanDefinitionStoreException:从类路径资源 [com/demo/spring/security-integration.xml] 解析 XML 文档时出现意外异常;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 bean 类 [org.springframework.security.config.SecurityNamespaceHandler]:构造函数抛出异常;嵌套异常是 java.lang.NoClassDefFoundError: org/springframework/security/config/method/InternalInterceptMethodsBeanDefinitionDecorator org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412) org.springframework.beans.factory.xml。 XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) org.springframework.beans.factory.xml.XmlBeanDefinitionReader。
org.springframework.beans.BeanInstantiationException:无法实例化bean类[org.springframework.security.config.SecurityNamespaceHandler]:构造函数抛出异常;嵌套异常是 java.lang.NoClassDefFoundError: org/springframework/security/config/method/InternalInterceptMethodsBeanDefinitionDecorator org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162) org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java: 104) org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.resolve(DefaultNamespaceHandlerResolver.java:129) org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1414) org.springframework.beans.factory。 xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.