The application I work on uses a system property to get a path to a file with other configuration properties. It is very difficult to change existing behavior. The system property is set at the time of Tomcat startup. I would like to have two instances of the application running under one server and the problem is that they share the same global system property.
Joined: Mar 22, 2005
I wouldn't put application properties into the system properties anyway. Why not have a Properties object that is unique to a web application? That would solve this immediate problem, and also ensure that different web apps don;t step on each others toes.
It may not be feasible to implement in your case, but I wouldn't keep two web apps (no matter where they're running) that differ only in some configuration details, and otherwise use the same code. That calls for a client capability built into the web app itself, so that it's possible to have one web app that reacts in two or more different ways depending on who's accessing it.
That being said, there are times when it makes sense to have various applications isolated from one another and it is possible to run multiple copies of Tomcat on a single machine, even from the same Tomcat codebase.
This from the 4x documentation but I'm fairly sure the process is the same for current versions. I've done this with 5.0.28
In many circumstances, it is desirable to have a single copy of a Tomcat 4 binary distribution shared among multiple users on the same server. To make this possible, you must configure a CATALINA_BASE environment variable (in addition to CATALINA_HOME as described above) that points to a directory that is unique to your instance.
When you do this, Tomcat 4 will calculate all relative references for files in the following directories based on the value for CATALINA_BASE instead of CATALINA_HOME:
* conf - Server configuration files (including server.xml)
* logs - Log and output files
* shared - For classes and resources that must be shared across all web applications
* webapps - Automatically loaded web applications
* work - Temporary working directories for web applications
* temp - Directory used by the JVM for temporary files (java.io.tmpdir)
If you do not set CATALINA_BASE to an explicit value, it will be initialized to the same value as is set for CATALINA_HOME (which means that the same directory is used for all relative path resolutions).
The administration and manager web applications, which are defined in the $CATALINA_BASE/webapps/admin.xml and $CATALINA_BASE/webapps/manager.xml will not run in that configuration, unless either: - The path specified in the docBase attribute of the Context element is made absolute, and replaced respectively by $CATALINA_HOME/server/webapps/admin and $CATALINA_HOME/server/webapps/manager - Copying and linking both web applications in $CATALINA_BASE, and modify accordingly the path specified in the docBase attribute of the Context element - Disabling both web applications by removing $CATALINA_BASE/webapps/admin.xml and $CATALINA_BASE/webapps/manager.xml