If you (or someone else) have full control of the database configuration, not your customers, you may consider using a true JDNI server. The JNDI implementation provided by Tomcat (or most of the app servers in the market today) are not true JDNI services, but only a look-up table, because objects bound as JNDI resources are available only to "clients" within the same app server. A "true" JDNI server (e.g. LDAP-based) would allow remote look-up of objects, so that naming functions can be made independently from application (war file) packaging and deployment.
One such JNDI server is the COBRA's CosNaming provided by JDK. Please see instructions on tnameserv under the "Java IDL and RMI-IIOP Tools" section of JDK doc for more details. You will have to create a simple Java client to register your DB with the naming server, and make corresponding coding change in the web app to retrieve DB resource. ND -----Original Message----- From: Darren [mailto:[EMAIL PROTECTED] Sent: Friday, February 17, 2006 11:00 AM To: users@tomcat.apache.org Subject: Where to place JNDI sections for customer deployment Hi, I am running Tomcat 5.5.9 and would like to deploy an application (as a war file) to various customers, but I am having trouble finding the best place for JNDI lookups. During development I kept everything inside the war file and placed my JNDI entries in $WAR/META-INF/ context.xml, but I don't want customers to have to edit the context.xml in the war file on their systems. So, I added the following into $WAR/WEB_INF/web.xml <resource-ref> <description>DB Connection</description> <res-ref-name>jdbc/db</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> <resource-ref> <description>Email Server Settings</description> <res-ref-name>bean/email</res-ref-name> <res-type>somepackage.EmailServerConfiguration</res-type> <res-auth>Container</res-auth> </resource-ref> Now I am unsure where to add the following .... <Context path="/mycontext" docBase="mycontext" crossContext="true" reloadable="true" debug="1"> <Resource name="jdbc/db" auth="Container" type="javax.sql.DataSource" maxActive="10" maxIdle="15" maxWait="10000" removeAbandoned="true" removeAbandonedTimeout="300" logAbandoned="true" driverClassName="com.mysql.jdbc.Driver" username="user" password="pass" url="jdbc:mysql://localhost:3306/db? autoReconnect=true" /> <Resource name="bean/email" auth="Container" type="somepackage.EmailServerConfiguration" factory="org.apache.naming.factory.BeanFactory" host="localhost" port="25" /> </Context> I tried adding it into $CATALINA/conf/server.xml inside the following host definition <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> but this meant the mycontext application was always visible in the manager and did not autodeploy when a war file was placed in $CATALINA/webapps (undeploy didn't appear to work either). I tried without the Context wrapper and the JNDI lookups failed. I see when an application is deployed tomcat makes it's own context configuration within $CATALINA/conf/Catalina/$HOST/$CONTEXT.xml which appears a good place to put the JNDI lookups. Only problem is this file is removed by tomcat when the application is undeployed. Am sure there must be a standard solution to this, so can anyone tell me how it is 'meant' to be done? Thanks, Darren --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]