- 浏览: 80947 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
neptunecai:
2.创建nutch2.1的编译环境 这部分能详细些吗?比如:T ...
Nutch2.1 in eclipse
Problem1:
Sometimes we can not get LDAP connection from LDAP server.
Cause1:
We can not close LDAP connection when program is end.
Solution1-1(don't do that):
Currently our code to close LDAP connection are as below,
LdapContext cladptx = null;
NamingEnumeration<?> results = null;
try {
cladptx = createConnection();
results = cladptx.search(ldapConnector.getEntry(), filter, constraints); } catch (Exception e) {
logger.error(e.getMessage(), e);
} finally {
try {
if (cladptx != null) {
cladptx.close();
}
} catch (Exception e2) {
logger.error(e2.getMessage(), e2);
}
}
But actually LDAP connection was not closed completely.
Solution1-2(Good solution):
We need to close various parameters of context and NamingEnumeration.Code as below,
LdapContext cladptx = null;
NamingEnumeration<?> results = null;
try {
cladptx = createConnection();
results = cladptx.search(ldapConnector.getEntry(), filter, constraints);
} catch (Exception e) {
logger.error(e.getMessage(), e);
} finally {
try {
if(results!=null) {
results.close();
}
if (cladptx != null) {
cladptx.close();
}
} catch (Exception e2) {
logger.error(e2.getMessage(), e2);
}
}
Problem2:
After I closed various parameters and ran a test which loops 4000 times on a LDAP client application, I observed the following errors in Windows Operating System when the load increased beyond a certain threshold:
javax.naming.CommunicationException: localhost:10389 [Root exception is java.net.BindException: Address already in use: connect]
at com.sun.jndi.ldap.Connection.<init>(Connection.java:210)
at com.sun.jndi.ldap.LdapClient.<init>(LdapClient.java:118)
</init></init>
Cause2:
The causes for the errors are that the dynamic ports in the OS are running out so that client application can not make any more connections to LDAP server.
Usually LDAP server is running on a specific port (say 10389) and when a connection is created from client, that is assigned a port in the range of dynamic ports which is defined as a property of Windows OS. This issue is not visible on Linux.
So the above errors can occur when no available ports are left.
Solution2:
We'd better use connection pool to solve this problem.See below code,
InitialDirContext context = null;
try {
System.setProperty("com.sun.jndi.ldap.connect.pool.maxsize", "50");
Hashtable<String,String> env = new Hashtable<String,String>();
//env.put("com.sun.jndi.ldap.connect.pool", "true");
context = new InitialDirContext(env);
} catch (NamingException e) {
logger.error(e.getMessage(),e);
}
Conclusion
1. Enable LDAP connection pooling when creating the connection to the LDAP..
2. Close all sub Contexts and NamingEnumerations derived from a particular LDAP connection Context, close them explicitly at the end of their usage.
Sometimes we can not get LDAP connection from LDAP server.
Cause1:
We can not close LDAP connection when program is end.
Solution1-1(don't do that):
Currently our code to close LDAP connection are as below,
LdapContext cladptx = null;
NamingEnumeration<?> results = null;
try {
cladptx = createConnection();
results = cladptx.search(ldapConnector.getEntry(), filter, constraints); } catch (Exception e) {
logger.error(e.getMessage(), e);
} finally {
try {
if (cladptx != null) {
cladptx.close();
}
} catch (Exception e2) {
logger.error(e2.getMessage(), e2);
}
}
But actually LDAP connection was not closed completely.
Solution1-2(Good solution):
We need to close various parameters of context and NamingEnumeration.Code as below,
LdapContext cladptx = null;
NamingEnumeration<?> results = null;
try {
cladptx = createConnection();
results = cladptx.search(ldapConnector.getEntry(), filter, constraints);
} catch (Exception e) {
logger.error(e.getMessage(), e);
} finally {
try {
if(results!=null) {
results.close();
}
if (cladptx != null) {
cladptx.close();
}
} catch (Exception e2) {
logger.error(e2.getMessage(), e2);
}
}
Problem2:
After I closed various parameters and ran a test which loops 4000 times on a LDAP client application, I observed the following errors in Windows Operating System when the load increased beyond a certain threshold:
javax.naming.CommunicationException: localhost:10389 [Root exception is java.net.BindException: Address already in use: connect]
at com.sun.jndi.ldap.Connection.<init>(Connection.java:210)
at com.sun.jndi.ldap.LdapClient.<init>(LdapClient.java:118)
</init></init>
Cause2:
The causes for the errors are that the dynamic ports in the OS are running out so that client application can not make any more connections to LDAP server.
Usually LDAP server is running on a specific port (say 10389) and when a connection is created from client, that is assigned a port in the range of dynamic ports which is defined as a property of Windows OS. This issue is not visible on Linux.
So the above errors can occur when no available ports are left.
Solution2:
We'd better use connection pool to solve this problem.See below code,
InitialDirContext context = null;
try {
System.setProperty("com.sun.jndi.ldap.connect.pool.maxsize", "50");
Hashtable<String,String> env = new Hashtable<String,String>();
//env.put("com.sun.jndi.ldap.connect.pool", "true");
context = new InitialDirContext(env);
} catch (NamingException e) {
logger.error(e.getMessage(),e);
}
Conclusion
1. Enable LDAP connection pooling when creating the connection to the LDAP..
2. Close all sub Contexts and NamingEnumerations derived from a particular LDAP connection Context, close them explicitly at the end of their usage.
发表评论
-
jetty 对请求头的限制
2014-02-13 14:30 5590当浏览器发起请求时 出现http code 413 问题 fu ... -
java 最基础的设置介绍
2013-04-15 23:05 1239用java不长不短快5年了,最近在看一些基础的书籍,也想起很久 ... -
Hessian 初体验
2013-03-27 17:36 1158Hessian 官网:http://hessian.cauch ... -
Nutch2.1 in eclipse
2013-03-10 00:22 9410Nutch2.1 in eclipse 主要目的: 1. 将 ... -
restlet2.0学习——请求超时设置
2012-09-26 11:01 2298一般,我们在请求一个rest service的时候,总是希望可 ... -
[转载]checkStyle使用手册
2012-08-23 20:28 6829Checkstyle是SourceForge下的一个项目,如名 ... -
[转载]高性能JAVA开发之内存管理
2012-08-13 21:53 1313这几天在找一个程序的bug,主要是java虚拟机内存溢出的问题 ... -
[转载]How to write LDAP search filters
2012-08-10 10:57 1390This document outlines how to g ... -
restlet2.0学习(extend)-restlet日志信息写入log4j中
2012-08-07 15:32 4010使用过restlet的人都知道,restlet使用的是JDK的 ... -
log4j级别输出
2012-08-03 11:12 4278我们知道: log4j.logger.XX cover ==& ... -
log4j配置
2012-05-30 11:36 1400log4j.rootLogger 根路径下的所有logger输 ... -
Restlet2.0学习——简单WebApp多Application与表单提交
2012-05-23 23:16 3532之前我们提到过简单的WebApp实现,使用的是一个applic ... -
Restlet2.0学习——文件路径访问
2012-05-22 14:42 1199由于就是官方的实例照搬了一下,简单尝试没有问题。就先把代码贴出 ... -
Restlet2.0学习——文件路径访问+BASIC认证
2012-05-22 14:38 1730这篇主要是让我们学习对于一些静态页面如何更加简单有效的去访问他 ... -
对RAM做简单的池化实现
2012-05-22 13:59 1517首先由于项目的关系需要使用IBM的Rational Asser ... -
Restlet2.0学习——简单WebApp实现
2012-05-21 22:09 6494由于自己最近正在学习R ... -
HTMLPOST和GET编码问题(深入篇)
2011-07-07 02:12 11367浏览器 IE/FireFox -------——----> ...
相关推荐
LDAP入門,LDAP入門LDAP入門LDAP入門LDAP入門LDAP入門LDAP入門LDAP入門LDAP入門LDAP入門LDAP入門LDAP入門
LdapBrowser2.82版,能浏览服务器的ldap数据,还有一份word详细使用文档及ldap安装说明
资源没有对LDAP创建的内容。 资源主要有: rar包:一个Web工程, 主要有,利用Spring-ldap对LDAP的基本操作(查询,增删改);Extjs实现的对Ldap的树状结构的显示,结构有点类似Softerra LDAP;一个测试类。 pdf:...
LdapBrowser282 ldap浏览器 LdapBrowser 查看openldap的好工具。 使用需要有JDK环境。
1 LDAP 基础 LDAP 的英文全称是 Lightweight Directory Access Protocol, 一般都简称为 LDAP。 它是基于 X.500 标准的,但是简单多了并且可以根据需要定制。与 X.500 不同,LDAP 支 持 TCP/IP,这对访问 Internet ...
LDAP是轻量级目录访问协议的简称(Lightweight Directory Access Protocol).用于访问目录服务。它是X.500目录访问协议的移植,但是简化了实现方法。本文给大家带来LDAP使用手册,需要的可以来下载看看 LDAP的优点 1:...
ldap安装与客户端ldapadmin windows版本,
基于RuoYi框架,使用的是ruoyi前后端不分离的版本,实现对LDAP的整合 基于RuoYi框架,使用的是ruoyi前后端不分离的版本,实现对LDAP的整合 基于RuoYi框架,使用的是ruoyi前后端不分离的版本,实现对LDAP的整合 基于...
c操作ldap例c操作ldap例c操作ldap例c操作ldap例c操作ldap例c操作ldap例c操作ldap例c操作ldap例c操作ldap例
这是一遍比较完整的linux下svn+apche+ldap安装配置手册,根据本人实际安装整理后的文档,目前都算是最新版本。其中ldap使用sun的opends,个人感觉比openldap要方便,当然重点不是用什么ldap而是如何配置。 主要包括...
项目中使用spring boot框架集成了ldap协议的方法,调用了增删改查的API,基本实现了spring boot对于ldap的所有方法,只要搭建好了ldap服务器,改一下配置文件即可运行。
# LDAP连接工具 LDAP是一种轻量级目录访问协议,用于在网络中访问分布式目录服务。要连接到LDAP目录,需要一种LDAP连接工具。 以下是一些常用的LDAP连接工具: ## 1. Apache Directory Studio Apache Directory ...
GitHub-Ldap 是 GitHub Enterprise 的一部分,是 LDAP 客户端。GitHub-Ldap 封装了 Net::LDAP,方便易用。 标签:GitHub
java操作ldap类java操作ldap类java操作ldap类
class="org.springframework.jdbc.... ${ldap.datasource.driverClassName}" /> ${ldap.datasource.url}" /> ${ldap.datasource.username}" /> ${ldap.datasource.password}" /> </bean>
LdapAdmin-1.8.3 win64下的ldap可视化管理工具,非常好用哦。
LDAPBrowser4.5 x86 32位系统使用的LDAP测试工具
LDAP的研究及其在统一身份认证系统中的应用 LDAP的研究与在校园网统一身份认证中的应用 基于LDAP的统一身份认证的设计与实现 基于LDAP的统一身份认证系统的实现 基于LDAP的校园网统一身份认证系统设计 基于LDAP和...
LDAPAdmin,最简单的LDAP管理客户端
Spring LDAP。 官网 Spring LDAP API。 Spring LDAP 开发文档。