Running Multiple instances of Tomcat
Hosting more than a single application in a single apache-tomcat server is not a new thing. It is a simple task. But many of us might be unaware of the potential danger we are putting ourselves by doing so, especially if each of the applications hosted are critical enough.
In such situation if a single application crashes, then it brings about a problem generally termed as “bad apple problem”. It results in the malfunctioning of other applications hosted in the same sever as well. Then comes the situation where running multiple instances of tomcat comes into play. Some of its main advantages are:
1. Avoid the bad apple problem.
2. Logs can be saved for each application individually.
3. Each application can be configured individually. ie. Update (upgrade/downgrade) of applications can be handled individually.
4. Stop/Start/Restart actions on one application can be performed without affecting tha other applications.
Now that we have known its importance, I’ll write about how to configure multiple instances of tomcat in a step by step manner.
Step 1:
Get binary distribution of apache-tomcat and install it. I have used tomcat 6.x but it should work with lower versions as well. Lets suppose the installation directory is C:\Program Files\Apache Software Foundation\Tomcat 6.0.
Step 2:
Make a shared folder somewhere to place a few configurations files that can be used by all instances of tomcat we are going to make. eg. C:\tomcat-instances\shared. Under shared folder make a folder named conf. Now copy server.xml and logging.properties from C:\~~\Tomcat 6.0\conf to C:\tomcat-instances\shared\conf.
Step 3:
In the next step we have to configure the server.xml. Modify Server.xml so that you can provide shutdown port, http port and host name in the runtime. Server port, http port and host name should be configured as shown below.
…………….
<Server port=“${shutdown.port}” shutdown=“SHUTDOWN”>
…………….
<Connector port=“${http.port}” protocol=“HTTP/1.1″
connectionTimeout=“20000″
redirectPort=“8443″ />………………..
<Host name=“${host.name}” appBase=“webapps”
unpackWARs=“true” autoDeploy=“true”
xmlValidation=“false” xmlNamespaceAware=“false”>
Step 4: Now that we have configured server, it is time to add new instances of tomcat. Inside C:\tomcat-instances create a folder named application1. Create folders so that you have the folders structure as:
tomcat-instances
- shared
- conf
- application1
- conf
- logs
- webapps
- work
- temp
Step 5:
Now copy catalina.properties and web.xml from C:\~~\Tomcat 6.0\conf to C:\tomcat-instances\application1\conf folder.
Edit the catalina.properties and add the following lines
http.port=8081
shutdown.port=8006
host.name=localhost
The shared Server.xml takes the values of http port, shutdown port and host name from this catalina.properties. If you want to make another instance of tomcat, repeat from step 4 with application2. Make sure you give different addresses for http.port, shutdow.port. eg. 8082 and 8007 respectively. host.name can be localhost in both cases.
Step 6:
Copy the war(eg. ROOT.war of your web application) file of your application to C:\tomcat-instances\application1\webapps
Step 7:
Now the tomcat has been configured, it is time to install a new window service for the instance of tomcat just configured. You can use Tomcat Service Manager(TSM) for this. Run TSM and use the following details to create a service named Application1.
Service Name: Application1
Catalina Home: C:\Program Files\Apache Software Foundation\Tomcat 6.0
Catalina Base: C:\tomcat-instances\application1
Tomcat Config File: C:\tomcat-instances\shared\conf\Server.xml
Java Home: Your Java Installation directory
Other values are filled automatically by the TSM.
Step 8:
Now you are almost done. From the Service menu in TSM, click on install/update. This will install the service for you. After the service has been successfully installed, click on Service –> Start to start the service.
Step 9:
Congratulations!!! You are done. Now open your favourite browser and type http://localhost:8081. Your application should be running… eNjoy!!!!!

The CR was so good that we carried some with us. It was almost 10:30 when we finished eating one of the best DBT. We bought the tickets and entered inside the park. We were very excited and in a real hiking mood. We entered the forest and continued to walk through the road. “Walking straight away through the road” was interesting but could have been better. We tried something different. After walking for some distance, we decided we need some rest and sat down for a while. Every one of us had our own style of taking rest. We climbed up to the Gumba and had some photographs there.
The most interesting thing we had there was a couple of cups of special drink, special because it was free.
(guess what….?). We started the journey, which I would say, was adventurous. We thought we were the first hikers to climb that hill, which may or may not be the truth. Hands on hands, we were supporting each other in climbing the hill. Shiraj was getting weak but he accompanied. The rocks were getting stiffer as we elevated. At a point, the place was so steep that we could only see the ground meters down. We kept strong to the bushes and kept climbing. There was no room for slippery legs. The more we climbed up, the
more adventurous the journey became. Thanks for a packet of biscuit that was providing Shiraj the energy to push forward. The approaching top was motivating us to climb more and the increasing difficulty was deteriorating our spirit. We were only about 20 meters shy of the top, when Shiraj declared he can’t continue. We could not force him as we know he was not fit and finally decided that we’ll complete the mission some other day.





