File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Correct use of CATALINA_BASE --help Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Reply Bookmark "Correct use of CATALINA_BASE --help" Watch "Correct use of CATALINA_BASE --help" New topic
Author

Correct use of CATALINA_BASE --help

Timothy Stone
Ranch Hand

Joined: Aug 01, 2001
Posts: 70
Fellow ranch hands,
I have a load balanced Tomcat (v4.0.6) configuration on Win2k using mod_jk + Apache 2 (details @ Ubeans. Working great in a production environment.
However, on occassion, about once a month, I have to update a JSP page (don't ask). I have to do this twice...once for each Tomcat instance's webapps. It dawned on me the other day when R'ingTFM that CATALINA_BASE may have been designed for exactly this reason.
So, do I elect one instance as the master, the other slave? Using CATALINA_BASE set to the master's otherwise CATALINA_HOME?
The directory hierarchy then might look something like--admire the ASCII art--:

setenv CATALINA_BASE /tomcatMaster
Is this the correct understanding and use? Thank you.
Tim
[ June 09, 2003: Message edited by: Timothy Stone ]

Timothy Stone, MIT, SCJP
http://www.petmystone.com/
"This Satan's drink [coffee] is so delicious, we shall cheat Satan and baptize it." --Pope Clement the VIII (1592-1605)
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

You know, this is an issue I've wondered about myself. I've done the load-balanced tomcats as an academic exercise, and I've never used CATALINA_BASE, so take this post with the proverbial grain of salt. But the more I look at CATALINA_BASE, the more useless it becomes. I'm probably missing something.

My original thoughts:

CATALINA_BASE is about using a single Tomcat installation that can be invoked twice (once for each of two shell scripts) and by using CATALINA_BASE instead of CATALINA_HOME, you can get each single instance of Tomcat to serve up different web apps, using different server.xml files, library jars, etc, etc.. but all from the same Tomcat binary. Two instances that don't conflict in any way, because all the potentially conflicting things are pointing to two different places, courtesy of CATALINA_BASE.

Except that's NOT the case... from the Tomcat docs:
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
* webapps - Automatically loaded web applications
* work - Temporary working directories for web applications
* temp - Directory used by the JVM for temporary files (java.io.tmpdir)

So uh... everything's the SAME!. Conf, work dir, webapps... exactly why did I need to use CATALINA_BASE again?

Putting aside that confusion for a second, for load balancing, we're talking about the *exact same setup, binary and webapps and everything*. Here's a proposed solution that doesn't use CATALINA_BASE.

Start tomcat2 as normal, but for the host element in server.xml, specify an appBase that is the same as tomcat1's.

Would this not accomplish the same thing? I'm asking because I just don't know. Also to watch out for... are there issues with two different Tomcat instances sharing things like working directories, like they would using CATALINA_BASE? In my solution, the only 'shared' element is the web applications.
Timothy Stone
Ranch Hand

Joined: Aug 01, 2001
Posts: 70
I agree that the documentation is confusing on this subject. I'll post this question to the user list at jakarta when at work as well and see if some of the regulars can offer more clarification.
Thanks for the reply. I guess this topic remains open for others to opine on.
Tim
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I'm sorry Tim, ignore my confusion. I've just re-read my own post, and it makes sense again. I thought that listing of directories was what was shared, but no, it's what is being made unique through CATALINA_BASE.

I imagine the best use of CATALINA_BASE is if you are a Tomcat hosting company. You'd only want to install Tomcat 4 one time, and have 'n' separate directories for your 'n' users of your Tomcat hosting service. That way, with one binary install, you can have 'n' different Tomcat instances running, and each person has their own server.xml file, etc, etc..


You could still use CATALINA_BASE for load balancing, but I wonder if "fooling" the two JVM's to use a single directory structure is asking for trouble?
 
IntelliJ Java IDE
 
subject: Correct use of CATALINA_BASE --help
 
Threads others viewed
catalina home
problem using manager application for each tomcat instance
Starting tomcat 4.1.12
CATALINA_BASE question
Tomcat 5.5.15 configuring multiple instances
developer file tools