I'm running 3 different servers, one machine - three different ports, for beta, gamma and production environments and would like to build to the beta environment and build WARs to promote to gamma and production. I think I have that under control.
Where I'm having issues is coming up with a configuration for the database. I want to run beta, gamma and production databses, for which I assume I'll run the same tables in different databases within the same mysql instance.
To that end I'd like to configure a resource at the server level that points to the correct db and has the same name across the three servers. This is where I get confused. The JNDI documentation says I should declare the resource in the context in server.xml, but 5.X tomcat doesn't declare contexts in server.xml and I'm building everything out of webapps/ROOT, so it doesn't seem to have any context file. The example for GlobalResources (which I've used to some success for authentication... except that some people had to log in multiple times for a single page and some didn't) seems to be for authentication. Can I use the JNDI example in the global resources section then add a resource link in the web.xml?
I'm really frustrated with this on an architecture level. It seems the Tomcat documents are contradictory and/or incomplete. I've yet to get a naming resource to work, I've been doing everything the old direct connect way... but that isn't as viable as I'm trying to make this into a mature dev environment.
I copied context.xml to the gamma server's conf directory and changed the db in the url from beta to gamma, copied the test page and web.xml with no modifications and each got data from the correct place. I'm much happier now, the data URL is abstracted from the app.
Another possible solution is to create 3 seperate context.xmls pointing to your beta, gama and production databases. Place the context.xml in the META-INF directory of each of your 3(beta, gama, production) WAR files.