Running Multiple Tomcats with Single Server Installation

Many times we come to a situation where we need to modify the server configuration such that it is specific to an application. And if we got more than one such application and we want each application to have its own defined configuration options, then it needs some sort of configuration. In this tutorial, I am going to discuss the changes you should make to have different instances of tomcat for each application.

1. Steps to configure multiple instances of the Tomcat server

I am using a Windows machine you I will be using the paths in Windows format. But the procedure to create multiple instances is the same in all other operating systems. Also, I am assuming that you want to create 2 new different instances of tomcat. Now start reading the complete steps to achieve the goal.

Step 1. Install Tomcat Server

This is a very obvious step to be in the first place. Let’s say our tomcat installation directory is “C:/tomcatServer“.

Step 2. Create 2 new different folders in different locations

These folders are for storing the instance-specific configuration and other data such as logs, and temp data.

Let’s say the new folders are “C:/tomcatInstanceOne” and “C:/tomcatInstanceTwo“.

Step 3. Copy the ‘conf’ folder into the instances folder from the server folder

This step is necessary to have different configurations for each instance. Any instance-specific configuration-related changes should be done in the related instance folder only.

Step 4. Create instance-specific startup.bat and shutdown.bat

These files will be needed to start and shut down a particular instance. The content of the files will be as below:


set CATALINA_HOME=C:\tomcatServer
set CATALINA_BASE=C:\tomcatInstanceOne


set CATALINA_HOME=C:\tomcatServer
set CATALINA_BASE=C:\tomcatInstanceOne

Place both files in ‘bin‘ folder inside both instance-specific folders. [e.g. Create folder C:/tomcatInstanceOne/bin and copy both files].

The first property (CATALINA_HOME) points to the location of the common information shareable between all running instances, while the other property (CATALINA_BASE) points to the directory where all the instance-specific information is stored.

Step 5. Create setenv.bat for setting instance-specific environment configuration

Create a file called setenv.bat in the “C:\tomcatInstanceOne\bin” (and in the second instance folder as well) directory to set any environment variables mentioned in C:\tomcatServer\bin\catalina.bat. This is the place to set system properties, JPDA addresses, etc.

Step 6. Create more folders for logs, temp etc.

Now it’s time to create more folders that will be used when your application will be actually running. These folders are logs, temp, webapps and work. Create them in both instance folders separately.

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.

For example, change the ports where Tomcat will be running/debugging.

First server.xml file

<connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<server port="8005" shutdown="SHUTDOWN"/>
<connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<connector port="8100" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

Second server.xml file

<connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<server port="8006" shutdown="SHUTDOWN"/>
<connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
<connector port="8101" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

After doing the above changes you should be able to launch multiple instances of the same tomcat server on your machine. Please let me know if you are stuck somewhere.

Happy Learning !!


Notify of
Most Voted
Newest Oldest
Inline Feedbacks
View all comments

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.

Our Blogs

REST API Tutorial

Dark Mode

Dark Mode