简体   繁体   English

JBoss 4.2.3:LDAP初始上下文加载缓慢

[英]JBoss 4.2.3: LDAP Initial Context loading slow

I am using Jboss 4.2.3 and I am trying to connect to LDAP server and calling this piece of code to create the initial context: 我正在使用Jboss 4.2.3,并且尝试连接到LDAP服务器并调用以下代码来创建初始上下文:

Hashtable<String, String> environment = new Hashtable<String, String>();
environment.put(Context.PROVIDER_URL, ldapUrl);
environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
environment.put(Context.SECURITY_AUTHENTICATION, "simple");
environment.put(Context.SECURITY_PROTOCOL, "ssl");
environment.put(Context.REFERRAL, "follow");
environment.put(Context.SECURITY_PRINCIPAL, principalName);
environment.put(Context.SECURITY_CREDENTIALS, plainPassword);
environment.put("com.sun.jndi.ldap.connect.pool", "true");
environment.put("com.sun.jndi.ldap.connect.timeout", "1500");


context = new InitialLdapContext(environment, null);

The Initial context creation is taking 12 seconds which is not acceptable. 初始上下文创建需要12秒,这是不可接受的。 However, if I run this same program as a standalone java program in the same system, it executes in 1 second. 但是,如果我在同一系统中运行与独立Java程序相同的程序,它将在1秒钟内执行。

How can I analyse the cause for this delay inside the JBoss server ? 如何分析JBoss服务器内部此延迟的原因? How do I debug this problem ? 如何调试此问题? Kindly help 请帮助

Apparently, the culprit was the following piece of code, which was the cause for the delay: 显然,罪魁祸首是以下代码,这是造成延迟的原因:

environment.put("com.sun.jndi.ldap.connect.timeout", "1500");

Even the debug logs confirmed that the delay was happening when an attempt was being made to set the connection timeout. 甚至调试日志都确认尝试设置连接超时时发生延迟。

Apparently, it seems from the following links, that connection time out does not work when Ldap connection is made with ssl. 显然,从以下链接看来,当使用ssl建立Ldap连接时,连接超时不起作用。

Link 1 链接1

Link 2 连结2

Removing this line of code solved the issue. 删除此行代码即可解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM