[英]Unable to configure JNDI Read & Connect Timeout properties through Java VM options
I have configured JNDI read & connect timeout properties through VM options as shown below: 我已经通过VM选项配置了JNDI读取和连接超时属性,如下所示:
-Dcom.sun.jndi.ldap.connect.timeout=5000
-Dcom.sun.jndi.ldap.read.timeout=5000
But it is not working. 但这是行不通的。 JNDI read time out fails with below exception:
JNDI读取超时失败,发生以下异常:
javax.naming.NamingException: LDAP response read timed out, timeout used:-1ms.
But if I configured these properties in JNDI environment properties as shown below: 但是,如果我在JNDI环境属性中配置了这些属性,如下所示:
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.
The simple answer is that JNDI properties are not system properties, so setting them as system properties has no effect. 简单的答案是JNDI属性不是系统属性,因此将它们设置为系统属性无效。 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. 您可以在
Context
环境中提供它们,也可以通过JAR文件根目录中的/jndi.properties
文件提供它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.