遇到一个怪怪的问题:
org.springframework.ldap.CommunicationException: connection closed; nested exception is javax.naming.CommunicationException: connection closed [Root exception is java.io.IOException: connection closed]; remaining name 'cn=001'
到javaeye上搜了下,找不到类似问题,只是说CommunicationException是协议错误。
看到很多关于这方面的异常都是出现在证书错误方面,没有出现IOException。
当出现该异常之后,后面的连接居然都连不上了。
修改了一下Spring LDAP配置,去掉了pool可以了。记录下此问题,以后再慢慢补充。
<!-- spring ldap source配置 -->
<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
<property name="url" value="ldap://192.168.0.1:389/" />
<property name="base" value="cn=test,DC=SCTEL,DC=COM,DC=CN" />
<!--<property name="referral" value="follow"></property>-->
<property name="userDn" value="cn=root" />
<property name="password" value="123456" />
</bean>
<!--<bean id="poolingContextSource" class="org.springframework.ldap.pool.factory.PoolingContextSource">
<property name="contextSource" ref="contextSource" />
<property name="maxActive" value="20" />
<property name="maxTotal" value="40" />
<property name="maxIdle" value="10" />
<property name="minIdle" value="5" />
<property name="maxWait" value="5" />
</bean>-->
<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
<constructor-arg ref="contextSource" />
<!--<property name="contextSource" ref="poolingContextSource" />-->
</bean>
<bean id="springLdapDao" class="com.zzt.ldap.SpringLdapDao">
<property name="ldapTemplate" ref="ldapTemplate" />
</bean>
<bean id="ldapManager" class="com.zzt.ldap.LdapManager">
<property name="springLdapDao" ref="springLdapDao" />
</bean>
-----------------------------------------------------------------------------------------------------------------
补充:找出问题原因了,如下
当LDAP服务器重新启动之后,客户端无法重连导致上面问题的产生,配置修改如下就可以了
还是使用 poolingContextSource 这个bean,在该bean中添加
<property name="dirContextValidator" ref="dirContextValidator" />
<property name="testOnBorrow" value="true" />
<property name="testWhileIdle" value="true" />
引用的bean为:
<bean id="dirContextValidator" class="org.springframework.ldap.pool.validation.DefaultDirContextValidator" />
附件给出了SpringLDAP测试代码。
包含的jar文件:
commons-lang.jar
commons-logging.jar
commons-pool-1.3.jar
spring.jar
spring-ldap-1.3.0.RELEASE-all.jar
分享到:
相关推荐
Practical Spring LDAP is your guide to developing Java-based enterprise applications using the Spring LDAP Framework. This book explains the purpose and fundamental concepts of LDAP before giving a ...
Spring LDAP。 官网 Spring LDAP API。 Spring LDAP 开发文档。
基于springldap的增删改查,以及通过ldap的用户名、密码进行验证
SpringLDAP和JNDI增删改查的入门级例子 能够通过编译和运行 已经包含了需要的包,用eclipse导入即可
Spring LDAP is a Java library for simplifying LDAP operations, based on the pattern of Spring's JdbcTemplate. The framework relieves the user of common chores, such as looking up and closing contexts,...
spring ldap 1.3.0的全部jar包下载
spring ldap的使用
学习SpringSecurity时,看到LDAP认证,不了解LDAP根本无从下手。所以转头学习了一下LDAP,搭建了一个DEMO,仅作记录。 LDAP(Lightweight Directory Access Protocol) 轻量级目录访问协议,LDAP目录以树状的层次结构...
Practical Spring LDAP英文原版
springldap增删改查的源码 适合初学者下载学习 写的很简答 注释中加入了自己写代码遇到的问题解决方案和心得
使用spring-ldap-core测试链接ldap com.ldap.test.service包下为Junit测试类
NULL 博文链接:https://xrb2008.iteye.com/blog/650632
NULL 博文链接:https://ssailyang.iteye.com/blog/1248407
rar包:一个Web工程, 主要有,利用Spring-ldap对LDAP的基本操作(查询,增删改);Extjs实现的对Ldap的树状结构的显示,结构有点类似Softerra LDAP;一个测试类。 pdf:spring-ldap-reference.pdf Extjs.pdf ...
NULL 博文链接:https://andilyliao.iteye.com/blog/644326
SpringLdap 本项目为测试使用Spring操作LDAP 主要POM依赖 <groupId>org.springframework <artifactId>spring-context <version>3.2.9.RELEASE <groupId>org.springframework.ldap ...
Spring 实现LDAP 域认证,内有个人项目的实例分析,,希望大家参考,也可以给意见
spring-ldap1.3.1,一种框架技术用来实现对ldap服务器增删改查数据的工具包。
spring_ldap1.3的chm格式api