问题
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