views:

1625

answers:

2

The RUNNING.txt that accompagne with tomcat distribution indicates the use of CATALINA_BASE variable to enable multiple tomcat instance. But how can i set the CATALINA_BASE environment variable for each tomcat instance directory.

Thank you.

+3  A: 

Having multiple Tomcat instances on your development machine is great. Here's how I usually do it for Windows (the short answer to your question is in steps 3, 4 and 5):

  1. Install a copy of Tomcat 6 to a directory (like C:\apache-tomcat-6.0.20).
  2. Copy the conf directory to another directory (like C:\tomcat-1)
  3. Under C:\tomcat-1, create a bin directory
  4. In the C:\tomcat-1\bin directory, create a file called startup.bat that reads like this:

    set CATALINA_BASE=C:\tomcat-1

    C:\apache-tomcat-6.0.20\bin\startup.bat

  5. In the C:\tomcat-1\bin directory, create a file called startup.bat that reads like this:

    set CATALINA_BASE=C:\tomcat-1

    C:\apache-tomcat-6.0.20\bin\shutdown.bat

  6. OPTIONAL: create a file called setenv.bat in the C:\tomcat-1\bin directory to set any environment variables mentioned in C:\apache-tomcat-6.0.20\bin\catalina.bat. This is the place to set system properties, JPDA addresses, etc.

  7. Create the logs, temp, webapps and work directories under C:\tomcat-1
  8. From the C:\tomcat-1 directory, run bin\startup.bat
  9. Repeat for your other installs from step 2 for as many tomcat instances as you need.

Try not to install Tomcat in a directory that has spaces in its name. It should work, but you'll experience fewer problems that way. I do not know how this would work if you were using the "tomcat as a service" option for Windows.

From here, you should be able to isolate tomcat instances. Just be sure to edit your conf\server.xml file so that the shutdown ports and HTTP connector ports don't interfere with other Tomcat instances that may be running. I usually assign values like 8005, 8006, 8007, etc. for the shutdown port and 8080, 8081, 8082, etc. for the HTTP connector port.

Andy Gherna
+1  A: 

There is an easier way. Simply don't define the CATALINA_HOME as a Environment variable on your machine. startup.bat and shutdown.bat already come with the following code:

if not "%CATALINA_HOME%" == "" goto gotHome
set "CATALINA_HOME=%CURRENT_DIR%"

You should be all set. PS: Remember to edit server.xml and put a new port number though. :)

Sri