无法配置JNDI读和写通过Java VM选项连接超时属性 [英] Unable to configure JNDI Read & Connect Timeout properties through Java VM options
问题描述
我已将JNDI配置为读取&通过VM选项连接超时属性,如下所示:
I have configured JNDI read & connect timeout properties through VM options as shown below:
-Dcom.sun.jndi.ldap.connect.timeout=5000
-Dcom.sun.jndi.ldap.read.timeout=5000
但是它不起作用. JNDI读取超时失败,出现以下异常:
But it is not working. JNDI read time out fails with below exception:
javax.naming.NamingException: LDAP response read timed out, timeout used:-1ms.
但是,如果我在JNDI环境属性中配置了这些属性,如下所示:
But if I configured these properties in JNDI environment properties as shown below:
env.put("com.sun.jndi.ldap.read.timeout", "5000");
env.put("com.sun.jndi.ldap.connect.timeout", "5000");
然后它可以正常工作,在读取超时时,我得到正确的错误消息,如下所示:
Then it works correctly I get the proper error message for the read time out as shown below:
javax.naming.NamingException: LDAP response read timed out, timeout used:5000ms.
推荐答案
简单的答案是JNDI属性不是系统属性,因此将它们设置为系统属性无效.您可以在Context
的环境中提供它们,也可以通过JAR文件的根目录中的/jndi.properties
文件提供它们.
The simple answer is that JNDI properties are not system properties, so setting them as system properties has no effect. You can provide them either in the environment of a Context
or else via a /jndi.properties
file in the root directory of your JAR file.
这篇关于无法配置JNDI读和写通过Java VM选项连接超时属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!