Spring LDA:contextSource Bean的问题

ktm*_*124 3 java xml spring ldap spring-ldap

我正在编写一个使用LDAP的Spring应用程序.这是我的bean文件.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="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">

   <bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
      <property name="url" value="xxxxx:xxx" />
      <property name="base" value="ou=xxxxx,dc=xxxxxxx,dc=xxxxxx" />
      <property name="userDn" value="uid=xxxxxxx" />
      <property name="password" value="xxxxxxxx" />
   </bean>

   <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
      <constructor-arg ref="contextSource" />
   </bean>

   <bean id="helloLdap" class="a.b.c.HelloLdap">
      <property name="ldapTemplate" ref="ldapTemplate" />
   </bean>

</beans>
Run Code Online (Sandbox Code Playgroud)

这是我的bean创建代码:

ApplicationContext fac = new ClassPathXmlApplicationContext(
                "a/b/c/ldap.xml");
HelloLdap hello = (HelloLdap) fac.getBean("helloLdap");
Run Code Online (Sandbox Code Playgroud)

这是我的错误消息:

线程"main"org.springframework.beans.factory.BeanCreationException中的异常:在类路径资源[xxxxxxxxxxxx]中定义名称为'contextSource'的bean时出错:设置属性值时出错; 嵌套异常是org.springframework.beans.PropertyBatchUpdateException; 嵌套的PropertyAccessExceptions(1)是:PropertyAccessException 1:org.springframework.beans.MethodInvocationException:属性'base'抛出异常; 嵌套异常是java.lang.NoClassDefFoundError:org/apache/commons/lang/StringUtils

所以它说(最重要的)

"Property 'base' threw exception". 
Run Code Online (Sandbox Code Playgroud)

我想知道这是否是因为身份验证需要StartTLS.我没有在我的beans文件中的任何地方指示StartTLS身份验证,因此可能导致错误.不过,我希望在创建bean 之后,而不是在创建bean期间进行身份验证.

有谁知道这是不是原因(StartTLS authenticaton)?如果没有,任何想法我在我的XML中做错了什么?

谢谢,ktm

ska*_*man 5

答案在错误消息中:

java.lang.NoClassDefFoundError:org/apache/commons/lang/StringUtils

应用程序中的某些东西需要Apache Commons Lang.下载它,将其添加到您的类路径.