Unable to configure JNDI Read & Connect Timeout properties through Java VM options

时光怂恿深爱的人放手 提交于 2019-12-25 17:20:43

问题


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

But it is not working. JNDI read time out fails with below exception:

javax.naming.NamingException: LDAP response read timed out, timeout used:-1ms.

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.

回答1:


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.



来源:https://stackoverflow.com/questions/37268701/unable-to-configure-jndi-read-connect-timeout-properties-through-java-vm-optio

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!