2011-01-20 99 views
3

我正在编写使用LDAP的Spring应用程序。这是我的beans文件。Spring LDA:与contextSource 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> 

这里是我的豆创建代码:

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

这是我的错误信息:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contextSource' defined in class path resource [xxxxxxxxxxxx]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'base' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils

所以说,(最重要的)

"Property 'base' threw exception". 

我想知道这是否是因为认证要求StartTLS。我没有在我的beans文件中的任何地方指出StartTLS身份验证,所以也许会导致错误。不过,我期望认证在豆创建后,而不是在创建期间发生。

有谁知道这是否是原因(StartTLS authenticaton)?如果没有,我的XML有什么错误的想法吗?

感谢, KTM

回答

5

答案是错误消息:

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

东西在应用程序需要Apache Commons Lang。下载它,将它添加到你的类路径中。

+0

哇,这是一个快速反应!我会这样做,让你知道它是否有效。 *十字手指* – ktm5124 2011-01-20 19:31:15