wood burning stoves 2.0*
The moose likes Tomcat and the fly likes How to create a multiple tomcat instances in windows? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How to create a multiple tomcat instances in windows?" Watch "How to create a multiple tomcat instances in windows?" New topic
Author

How to create a multiple tomcat instances in windows?

PS Toh
Greenhorn

Joined: Sep 20, 2006
Posts: 7
hi,

1st of all Im a tomcat and apache noob, but my current job require me to do this.

i know this question had been asked alot and I also had done research on it, just cannot find a complete guide. I also had read doc from official website which only tell the concept.

what i know now is it has something to do with mod_jk, server.xml(changing port), workers.properties and service creation.

Can someone help me on this or direct me to any detail documentation?

Thanks in advance.
[ September 20, 2006: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

PS Toh, welcome to the Ranch.

In order to make the most efficient use of JavaRanch as a resource please resist the urge to abbreviate words like "first" with "1st". You'll find that people will be more receptive to your questions when you take the time to enter them thoughtfully.

With regards to your question, do you really need multiple instances of Tomcat, or are you just trying to support multiple web applications? It is rarely necessary to have multiple server instances.

If you could explain why you feel you need multiple instances, it'd give everyone a better idea of your needs.
[ September 20, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You can have as many as you want.
You just can't have more than one bound to a particular port.

In your server.xml file there are two ports that will need to be changed.
The first is your non-secure connector (search for 8080). One of your copies will have to have that changed.

The other is the SHUTDOWN port 8005. This, also will need to be changed in one of the copies.

If you're using SSL, then you will also need to change the secure connector's port.

Once you've done this, you can start both up and access them with
http://localhost:PORT_NUMBER.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Bear Bibeault:

With regards to your question, do you really need multiple instances of Tomcat, or are you just trying to support multiple web applications? It is rarely necessary to have multiple server instances.


I'm not sure what PS Toh's reason is but, our product uses some middleware that has JNI components. The jars for this middleware component need to be in a shared directory and have static components.
Becuase of this, the only way to guarantee a real clean restart is to restart the entire app server.

So.. to keep dev from interrupting QA and QA from interrupting demo, I keep them all under their own instance of Tomcat.

It's also helpful in hosted situations where you don't want one client's crappy, leaky code to be able to bring down another client's site.
PS Toh
Greenhorn

Joined: Sep 20, 2006
Posts: 7
Thanks for all the quick replies.

Ok, let me explain in more detail on what I need.

My boss asked me to create multiple instances, said like he want 3 tomcat services running in windows service, eg: tomcat-dev, tomcat-support, and tomcat-testing. Each of this services can be start and shut down independently without affecting others service. For example, the support group want to restart their service but will not affect developer staff.

I have research a lot for the creation of multiple tomcat instances, however most of them are discussed in Linux.

I have also tried to create a new folder named tomcat-testing then create folders named conf, logs, works, webapps inside it. After that I copy server.xml from original tomcat to the new conf directory then change all the port as Ben said. However, this does not work for me, I think there should be something that I had missed out.

Then I research again which some article said need to use mod_jk in apache and need to create a workers.properties files. However, due to my lacking of Tomcat and apache knowledge, these articles can give some concepts but cannot make my things working.

Now I am stucked and don't know how to proceed. So, if somebody can guide me how to do this step by step, I will be really grateful to him.

Thanks in advance.
PS Toh
Greenhorn

Joined: Sep 20, 2006
Posts: 7
Ok, here is what I had done so far.

1. installing J2sdk1.4.2_09,Tomcat 4.1,Apache 2.0.54,mod_jk 1.2.14
2. set my JAVA_HOME= C:\J2sdk1.4.2_09
set my CATALINA_HOME=d:\tomcat 4.1
3. put these in my apache2 httpd.conf:
#
# Load mod_jk
#
LoadModule jk_module modules/mod_jk.dll

#
# Configure mod_jk
#
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info

JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"

4.create a workers.properties file

worker.list=worker1,worker2,worker3
# Set properties for worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
# Set properties for worker2
worker.worker2.type=ajp13
worker.worker2.host=localhost
worker.worker2.port=8109
# Set properties for worker3
worker.worker3.type=ajp13
worker.worker3.host=localhost
worker.worker3.port=8209

5. create instance1, instance2 and instance3 in tomcat4 directories.
6. all the new instances folder contains webbapps, conf, log, works,temp folder.

6. port number of server.xml in conf folder in each instances folder had been modified according to worker.properties.

7. put this in httpd.conf again:
<VirtualHost *:80>
ServerName domain1
JkMount /servlets-examples/* worker1
</VirtualHost>
<VirtualHost *:80>
ServerName domain2
JkMount /servlets-examples/* worker2
</VirtualHost>
<VirtualHost *:80>
ServerName domain3
JkMount /servlets-examples/* worker3
</VirtualHost>

8. I create service for instance1, instance2 and instance3 using tcservcfg.exe from http://web.bvu.edu/staff/david/index.jsp?section=software&subsection=tcservcfg&page=downloads

9. 3 new services had been created and can be started indepently in windows service.

So, theoritically, when I type http://domain2/index.jsp i should get some result because I already create some jsp file in webapps root in instance2 folder. However, I just got The page cannot be displayed message. This means I must have something wrong in my configuration above.

I had been finding ways to create multiple tomcat instances in windows for 3 days and now stucked here.

Can someone show me what I had done wrong, please guide me.

Thanks!
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Sorry if I seem a little fuddled here but - it appears you are talking about an installation where the Apache web server is the frontend and Tomcat is supposed to handle JSP and servlets via the mod_jk connector.

Is that really essential for the alternate Tomcat installations also?

Bill
PS Toh
Greenhorn

Joined: Sep 20, 2006
Posts: 7
I refer the article "Connecting Apache's Web Server to Multiple Instances of Tomcat" from web http://www.linuxjournal.com/article/8561

What I have done now is i can access
http://localhost:8080
http://localhost:8081
http://localhost:8082

However, I cannot access status, administration and manager pages at index.jsp for 8081 and 8082 port.

Does anyone know how to solve this?

Thanks.
G Nair
Greenhorn

Joined: Sep 28, 2009
Posts: 17
Hi as there was a practical question asked to me in to create multiple instances of tomcat on single server , after reading lot of article in google and then carried following steps , but cant access other two instances created for tomcat.

1.Have actual tomcat directory at C:\Program Files\apache-tomcat-6.0.20 which has bin directory

2. created two instances of tomcat server under path
C:\Program Files\Tomcat\server1 and C:\Program Files\Tomcat\server2

3. copied log, conf , webapp,temp and work along with server.xml from tomcat at step 1

4. changed port numbers in server.xml to diffrent and unique in each instances server.xml
e.g. for server1
<Server port="8004" shutdown="SHUTDOWN">

<Connector port="8079" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

<Connector port="8008" protocol="AJP/1.3" redirectPort="8443" />

similarly for server2 and diffrent and unique ports

5. I set environment varibles as CATALINA_HOME =C:\Program Files\apache-tomcat-6.0.20 and JAVA_HOME = C:\Program Files\jdk1.5.0_06

6. then i started tomcat by following command at command prompt
C:\Program Files\apache-tomcat-6.0.20\bin>startup.bat

7.Opened IE and hit all the following site in diffrent tabs of IE

http://localhost:8080/ -- For C:\Program Files\apache-tomcat-6.0.20 -- worked fine

http://localhost:8079/ -- For server1 -- did not open required tomcat site

http://localhost:8078/ -- For server2 -- did not open required tomcat site

Can some one help me in identifying the mistake i have done and guide me the right way to do this
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
G Nair wrote: then i started tomcat by following command at command prompt
C:\Program Files\apache-tomcat-6.0.20\bin>startup.bat


Looks like you have started only one Tomcat instance. You could compare your steps with these ones Running multiple Tomcat instances on Windows
 
 
subject: How to create a multiple tomcat instances in windows?
 
Similar Threads
disable tomcat version display
Creating a simple html page filter.
scalability and availibility in tomcat
regarding proxy configuration
Deploying Servlet in Tomcat 5.0