问题描述
按照网上的讲解,配置ldap+cas时要配置deployerConfigContext.xml但是怎么配怎么错,错误如下:SafeDispatcherServlet:TheSpringDispatcherServletwewrapthrewoninit.Butforourhavingcaughtthiserror,theservletwouldnothaveinitialized.org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'centralAuthenticationService'definedinServletContextresource[/WEB-INF/applicationContext.xml]:Cannotresolvereferencetobean'authenticationManager'whilesettingbeanproperty'authenticationManager';nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'authenticationManager'definedinServletContextresource[/WEB-INF/deployerConfigContext.xml]:Initializationofbeanfailed;nestedexceptionisjava.lang.VerifyError:classorg.jasig.cas.adaptors.ldap.AbstractLdapUsernamePasswordAuthenticationHandleroverridesfinalmethodafterPropertiesSet.()VCausedby:org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'authenticationManager'definedinServletContextresource[/WEB-INF/deployerConfigContext.xml]:Initializationofbeanfailed;nestedexceptionisjava.lang.VerifyError:classorg.jasig.cas.adaptors.ldap.AbstractLdapUsernamePasswordAuthenticationHandleroverridesfinalmethodafterPropertiesSet.()VCausedby:java.lang.VerifyError:classorg.jasig.cas.adaptors.ldap.AbstractLdapUsernamePasswordAuthenticationHandleroverridesfinalmethodafterPropertiesSet.()Vatjava.lang.ClassLoader.defineClass1(NativeMethod)atjava.lang.ClassLoader.defineClass(ClassLoader.java:620)atjava.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)atorg.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1819)atorg.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:872)atorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1327)atorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)atjava.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)atjava.lang.ClassLoader.defineClass1(NativeMethod)atjava.lang.ClassLoader.defineClass(ClassLoader.java:620)atjava.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)atorg.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1819)atorg.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:872)atorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1327)atorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)atjava.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)atjava.lang.Class.forName0(NativeMethod)atjava.lang.Class.forName(Class.java:247)atorg.springframework.util.ClassUtils.forName(ClassUtils.java:160)atorg.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:324)atorg.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:833)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:317)atorg.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:174)atorg.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:105)atorg.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:241)atorg.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:118)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:801)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:592)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:392)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:240)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:132)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:237)在这个deployerConfigContext.xml中只要添加<beanclass="org.jasig.cas.adaptors.ldap.BindLdapAuthenticationHandler">就有这样的错误,里边没有内容也会错,但是这个是必须添加的啊。配置如下:<?xmlversion="1.0"encoding="UTF-8"?><!DOCTYPEbeansPUBLIC"-//SPRING//DTDBEAN//EN""http://www.springframework.org/dtd/spring-beans.dtd"><beans><beanid="authenticationManager"class="org.jasig.cas.authentication.AuthenticationManagerImpl"><propertyname="credentialsToPrincipalResolvers"><list><beanclass="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver"/><!--|HttpBasedServiceCredentialsToPrincipalResolversupportsHttpBasedCredentials.ItsupportstheCAS2.0approachof|authenticatingservicesbySSLcallback,extractingthecallbackURLfromtheCredentialsandrepresentingitasa|SimpleServiceidentifiedbythatcallbackURL.||IfyouarerepresentingservicesbysomethingmoreorotherthananHTTPSURLwhereattheyareableto|receiveaproxycallback,youwillneedtochangethisbeandeclaration(oraddadditionaldeclarations).+--><beanclass="org.jasig.cas.authentication.principal.HttpBasedServiceCredentialsToPrincipalResolver"/></list></property><!--|WhereasCredentialsToPrincipalResolversidentifywhoitissomeCredentialsmightauthenticate,|AuthenticationHandlersactuallyauthenticatecredentials.HerewedeclaretheAuthenticationHandlersthat|authenticatethePrincipalsthattheCredentialsToPrincipalResolversidentified.CASwilltrythesehandlersinturn|untilitfindsonethatbothsupportstheCredentialspresentedandsucceedsinauthenticating.+--><propertyname="authenticationHandlers"><list><!--|ThisistheauthenticationhandlerthatauthenticatesservicesbymeansofcallbackviaSSL,therebyvalidating|aserversideSSLcertificate.+--><beanclass="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"/><!--|ThisistheauthenticationhandlerdeclarationthateveryCASdeployerwillneedtochangebeforedeployingCAS|intoproduction.ThedefaultSimpleTestUsernamePasswordAuthenticationHandlerauthenticatesUsernamePasswordCredentials|wheretheusernameequalsthepassword.YouwillneedtoreplacethiswithanAuthenticationHandlerthatimplementsyour|localauthenticationstrategy.Youmightaccomplishthisbycodinganewsuchhandleranddeclaring|edu.someschool.its.cas.MySpecialHandlerhere,oryoumightuseoneofthehandlersprovidedintheadaptorsmodules.+--><!--<beanclass="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler"/>--><beanclass="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"/><beanclass="org.jasig.cas.adaptors.ldap.BindLdapAuthenticationHandler"><propertyname="filter"value="uid=%u"/><propertyname="searchBase"value="ou=users,o=tcl,c=cn"/><propertyname="contextSource"ref="contextSource"/></bean></list></property></bean><beanid="contextSource"class="org.springframework.ldap.core.support.LdapContextSource"><propertyname="anonymousReadOnly"value="true"/><propertyname="password"value="{password_goes_here}"/><propertyname="pooled"value="true"/><propertyname="urls"><list><value>ldap://jdeps:389/</value></list></property><propertyname="userDn"value="{username_goes_here}"/><propertyname="baseEnvironmentProperties"><map><entry><key><value>java.naming.security.protocol</value></key><value>ssl</value></entry><entry><key><value>java.naming.security.authentication</value></key><value>simple</value></entry></map></property></bean></beans>其中ldap为o=tcl,c=cnmanagersecrctou=groupsou=sysou=userou=userscn=joebloggscn=bruno
解决方案
本帖最后由 zn01611 于 2010-07-21 14:51:46 编辑