`

Spring LDAP

阅读更多

遇到一个怪怪的问题:

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

分享到:
评论
2 楼 Z_408 2014-01-02  
谢谢,找好多例子终于成功一个了
1 楼 Java-feifeiok 2011-09-28  
多谢 找了半天终于给解决了 再次感谢

相关推荐

    Spring LDAP API(Spring LDAP 开发文档).CHM

    Spring LDAP。 官网 Spring LDAP API。 Spring LDAP 开发文档。

    [Spring] Spring LDAP 实践开发 (英文版)

    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 读取数据并映射到 Java Bean 中

    Spring LDAP 是一个强大的框架,它允许开发者利用Java与 Lightweight Directory Access Protocol (LDAP) 服务器进行交互。这篇博客文章“使用 Spring LDAP 读取数据并映射到 Java Bean 中”主要探讨了如何通过Spring...

    spring ldap操作(一)目录测试环境搭建

    在本篇博客“spring ldap操作(一)目录测试环境搭建”中,我们将深入探讨如何在Java应用程序中使用Spring LDAP框架来操作LDAP(轻量级目录访问协议)服务器,以及如何搭建一个测试环境来验证和调试相关功能。Spring...

    基于springldap的增删改查以及验证

    在IT行业中,Spring LDAP是一个非常重要的框架,它为Spring应用提供了与LDAP(轻量级目录访问协议)服务器交互的能力。Spring LDAP使得开发人员能够利用Spring的IoC(控制反转)和AOP(面向切面编程)特性来处理LDAP...

    SpringLDAP和JNDI的增删改查

    **Spring LDAP与JNDI:增删改查详解** 在Java开发中,当我们需要与目录服务进行交互,例如用户认证、权限管理等,Spring LDAP和Java Naming and Directory Interface (JNDI)是两个常用的技术。本文将通过一个入门级...

    Spring LDAP 简单使用

    **Spring LDAP 简介** Spring LDAP 是一个用于简化Java应用程序与LDAP(轻量级目录访问协议)交互的框架。它构建在Spring框架之上,提供了一种声明式的方式来处理 LDAP 查询,使得开发者能够更容易地集成LDAP服务到...

    spring ldap 1.3.0下载

    Spring LDAP 是一个强大的Java库,它为开发人员提供了一个简单且直观的接口,用于与LDAP(轻量级目录访问协议)服务器进行交互。在本文中,我们将深入探讨Spring LDAP 1.3.0版本,包括它的特点、用途、安装过程以及...

    springldap例子

    这个"springldap例子"可能是为了展示如何配置和使用Spring LDAP进行开发。让我们深入了解一下Spring LDAP以及如何在实际项目中应用它。 Spring LDAP是一个模块化的框架,它为开发人员提供了在Java应用中集成LDAP...

    Practical Spring LDAP英文原版

    《Practical Spring LDAP》是一本面向中级Java开发者的专业书籍,专注于使用Spring LDAP框架构建企业级应用程序。Spring LDAP是Spring框架的一个扩展,旨在简化Java与 Lightweight Directory Access Protocol (LDAP)...

    spring ldap的使用

    标题与描述中的关键词“spring ldap的使用”指向的是在Spring框架下集成轻量级目录访问协议(Lightweight Directory Access Protocol,简称LDAP)的相关知识。Spring LDAP是Spring框架的一部分,它提供了一种简单的...

    SpringLdapDemo

    学习SpringSecurity时,看到LDAP认证,不了解LDAP根本无从下手。所以转头学习了一下LDAP,搭建了一个DEMO,仅作记录。 LDAP(Lightweight Directory Access Protocol) 轻量级目录访问协议,LDAP目录以树状的层次结构...

    spring-ldap1.3.1

    Spring LDAP 是一个强大的Java框架,专门设计用于简化与 Lightweight Directory Access Protocol (LDAP) 服务器的交互。在"spring-ldap1.3.1"版本中,这个框架提供了一个灵活且直观的API,允许开发者轻松地执行对...

    Spring 初步实现LDAP 域认证

    在本文中,我们将探讨如何使用Spring框架来实现LDAP(轻量级目录访问协议)域认证。这是一项重要的技术,特别是对于那些希望集中管理和验证多个应用系统账号密码的企业而言。通过集成Spring与LDAP,我们可以实现一个...

    spring ldap

    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,...

    springldap源码 增删改查

    springldap增删改查的源码 适合初学者下载学习 写的很简答 注释中加入了自己写代码遇到的问题解决方案和心得

    spring-ldap demo

    Spring LDAP 是一个基于 Spring 框架的 LDAP(轻量级目录访问协议)客户端库,它简化了在 Java 应用程序中与 LDAP 服务器的交互。本示例项目 "spring-ldap demo" 提供了一个关于如何使用 Spring LDAP 进行实际操作的...

    对LDAP的基本操作(Spring-ldap)+Ext实现显示LDAP的树状结构

    rar包:一个Web工程, 主要有,利用Spring-ldap对LDAP的基本操作(查询,增删改);Extjs实现的对Ldap的树状结构的显示,结构有点类似Softerra LDAP;一个测试类。 pdf:spring-ldap-reference.pdf Extjs.pdf ...

Global site tag (gtag.js) - Google Analytics