Developer’s Corner: Caveats in GeoServer JNDI configuration
as you may know JNDI is a very useful technology to define common resources available to Java web applications.
One typical usage is to create a common connection pool for databases.
Most of GeoServer JDBC based datastores support connection through JNDI (for example PostGIS, Oracle, SQLServer).
Using JNDI is convenient when you have more than one datastore using the same database connection, so that you can share the connection pool instead of create a distinct pool for each datastore: if you have many datastore you can fill database connection capacity and in any case you are not using the pools efficiently.
GeoServer documentation includes a tutorial to explain how to set a JNDI database connection within a Tomcat container. You can find it here.
Recently we had to configure one for a customer, to connect an Oracle database, where a different store was used for each schema in the database and we found a very frustrating issue that was not permitting bounding box calculation from the GeoServer Publish layer page. The issue was fixed removing the jdbc driver jar from the GeoServer WEB-INF/lib: in a JNDI configuration the JDBC driver is copied into the Tomcat shared library folders, so that the shared connection pool can use it. Having a copy also inside the application library folder was probably causing a classloader related conflict, so some operations that needed direct access to the underlying connection were not possible. We updated the above mentioned tutorial with a note to always remove the jdbc driver from the Geoserver libraries folder when you use JNDI, so you will find this advice on next Geoserver relelases.
The GeoSolutions team,