2014-11-08 80 views
0

我构建异步球衣web服务,现在我需要使用ldap进行一些操作。 我在这个模式下配置Spring beam.xml:Spring ldap pooling出错

<bean id="contextSourceTarget" class="org.springframework.ldap.core.support.LdapContextSource"> 
     <property name="url" value="${ldap.url}" /> 
     <property name="base" value="${ldap.base}" /> 
     <property name="userDn" value="${ldap.userDn}" /> 
     <property name="password" value="${ldap.password}" /> 
     <property name="pooled" value="false" /> 
    </bean> 

    <bean id="contextSource" 
     class="org.springframework.ldap.pool.factory.PoolingContextSource"> 
     <property name="contextSource" ref="contextSourceTarget" /> 
    </bean> 

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

    <bean id="ldapTreeBuilder" class="com.me.ldap.LdapTreeBuilder"> 
     <constructor-arg ref="ldapTemplate" /> 
    </bean> 


    <bean id="personDao" class="com.me.ldap.PersonDaoImpl"> 
     <property name="ldapTemplate" ref="ldapTemplate" /> 
    </bean> 

但是,当我尝试使用LDAP我有这样的错误:

Error creating bean with name 'contextSource' defined in class path resource [config/Beans.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/pool/KeyedPoolableObjectFactory 

在我的项目,我有公地pool2-2.2.jar LIB,但我仍然有这个error..i尝试添加公地pool2-2.2.jar在TOMCAT_PATH/lib目录但不是工程..

UPDATE:

如果我把commons-pool-1.6.jar工作..但如果我想使用pool2我该怎么办?只有我必须改变class class commons-pool2-2.2.jar?

回答

1

不幸的是,Spring-Ldap使用公共池而不是commons-pool2。正如您发现类commons-pool2中不存在类org.apache.commons.pool.KeyedPoolableObjectFactory(它具有不同的包结构),因此出现错误。

有一个JIRA问题为Spring-LDAP项目,要求他们升级/支持公地POOL2: https://jira.spring.io/browse/LDAP-316

在此之前,已经完成了,你将不得不使用commons-pool的1.6。

+0

现在支持commons-pool2 – Marged 2017-02-15 22:15:53