title: How can I set up an LDAP connection pool in a Java EE Container?
body: <p>I need to put an LDAP contextSource into my Java EE container's JNDI tree so it can be used by applications inside the container.</p>
  
  <p>I'm using Spring-LDAP to perform queries against ORACLE OVD. For development, I simply set up the contextSource in the Spring xml configuration file. For production, however, I need to be able to use a JNDI lookup to grab the connection/context from the container (as suggested here: <a href="http://forum.springframework.org/showthread.php?t=35122&amp;highlight=jndi" rel="noreferrer">http://forum.springframework.org/showthread.php?t=35122&amp;highlight=jndi</a>). I'm not allowed to have access to the URL/username/pwd for the production OVD instance, so that seems to rule out putting it in a jndi.properties file.</p>
  
  <p>Ideally, I'd like to have a pool of connections (just like JDBC), as my application may have many LDAP queries executing at the same time. Grabbing the object from a JNDI lookup and injecting it into my SimpleLdapTemplate seems pretty straightforward, but I'm at a loss as to how to get the connection/context/pool into the JNDI tree. Would I need to construct it and package it into a RAR? If so, what are some options for letting the operations team specify the URL/username/pwd in a way that they are not accessible to the developers?</p>
  
  <p>The specific container I'm using is OAS/OC4J, though I welcome strategies that have worked on other containers as well.</p>