简体   繁体   中英

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:

-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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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