Spring ldap池出错

DevOps85

我建立了异步球衣Web服务,现在我需要使用ldap进行一些操作。我已经在这种模式下配置了Spring beam.xml:

<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

在我的项目中,我有commons-pool2-2.2.jar lib,但仍然有此错误..我尝试在TOMCAT_PATH / lib中添加commons-pool2-2.2.jar但不起作用。

更新:

如果我把commons-pool-1.6.jar放到了..但是,如果我想使用pool2,我该怎么办?只有我必须更改class commons-pool2-2.2.jar吗?

DB5

更新的答案:

从至少Spring LDAP 2.3.2开始,您现在可以使用commons-pool2。Spring LDAP现在提供了两个类:

对于Commons-pool 1.x: org.springframework.ldap.pool.factory.PoolingContextSource

对于Commons-pool 2.x: org.springframework.ldap.pool2.factory.PooledContextSource

可以在这里找到详细信息:https : //github.com/spring-projects/spring-ldap/issues/351#issuecomment-586551591

原始答案:

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

Spring-ldap项目有一个Jira问题,要求他们升级/支持commons-pool2:https ://jira.spring.io/browse/LDAP-316

在完成此操作之前,您将必须使用commons-pool 1.6。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章