I've found that some developers try to set JNDI properties via environment variables and then wonder why their settings don't seem to hold. For example, a developer might create a Hashmap (env) and set their JNDI property value using Hashmap.put(),
Now the LDAP_CONNECTION_POOL_MAX_SIZE value is definitely set to 5, but Java/JNDI won't honor it and will allow programs to create as many connections as they want.
The reason for this is that JNDI properties *cannot* be set via environment from within Java and must be set as System properties using one of the following methods:
1.) Add "-Dcom.sun.jndi.ldap.connect.pool.maxsize=5" to the java command line when running your application.
or
2.) Set the com.sun.jndi.ldap.connect.pool.maxsize as a system property from within your code, i.e.,
The documentation which verifies this is at: http://java.sun.com/j2se/1.4.2/docs/guide/jndi/jndi-ldap.html
Section 15.3 Global Configuration
"Connection pooling is configured by a number of System properties at runtime startup time. Note that these are System properties, not environment properties and that they affect all connection pooling requests. "
-
public static final String LDAP_CONNECTION_POOL_MAX_SIZE = "com.sun.jndi.ldap.connect.pool.maxsize";
env.put(LDAP_CONNECTION_POOL_MAX_SIZE,"5");
Now the LDAP_CONNECTION_POOL_MAX_SIZE value is definitely set to 5, but Java/JNDI won't honor it and will allow programs to create as many connections as they want.
The reason for this is that JNDI properties *cannot* be set via environment from within Java and must be set as System properties using one of the following methods:
1.) Add "-Dcom.sun.jndi.ldap.connect.pool.maxsize=5" to the java command line when running your application.
or
2.) Set the com.sun.jndi.ldap.connect.pool.maxsize as a system property from within your code, i.e.,
- System.setProperty("com.sun.jndi.ldap.connect.pool.maxsize", "5");
The documentation which verifies this is at: http://java.sun.com/j2se/1.4.2/docs/guide/jndi/jndi-ldap.html
Section 15.3 Global Configuration
"Connection pooling is configured by a number of System properties at runtime startup time. Note that these are System properties, not environment properties and that they affect all connection pooling requests. "
