This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes multiple jvm for tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "multiple jvm for tomcat" Watch "multiple jvm for tomcat" New topic
Author

multiple jvm for tomcat

ray bond
Ranch Hand

Joined: Oct 11, 2000
Posts: 111
hello there , can anybody tell me that:
how can i have two instance of tomcat running on a single machine and each instance is using separate java virtual machine(running multiple jvm).
thanks
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

If you had each instance listen on a different port. I've used JBuilder 5 to test and run JSP pages. Each time I click the green arrow, I can set JBuilder to start a new instance... so I have tomcat:8080, tomcat:8082, tomcat:8084

Absolute proof that they are different JVM's is that the servlet error I fixed on my third try (which runs properly in 8084) is still broken in the first window (8080).

If you meant something like two jvm's that round-robin on a single port for load balancing.. I'm not sure if Tomcat supports this? anyone else?
[This message has been edited by Mike Curwen (edited October 16, 2001).]
ray bond
Ranch Hand

Joined: Oct 11, 2000
Posts: 111
I created two directory for tomcat
1. c:\jakarta-tomcat , 2.c:\jakarta-tomcatone .
each instance have different port, but the second
instance I start is giving error "JVM bind error......"
it means both instances are running in same
JVM , how can I get each instace running in different
JVM (two JVM for two instace).
thanks
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

No, you are still running two JVM's, but the BIND error means you are trying to get your second instance of Tomcat to bind to a port the first one is using.

If you look in server.xml there are many ports that Tomcat binds (off hand, I can remember 8080, 8081, 8082, 8008 and 8443)

What I did was make two directories like you, and in my second server.xml file, I changed all of the 8*** ports to 9***, and two instances started up (from two different DOS windows). I should say that perhaps changing *all* of these numbers is not necessary, I really don't know. But for safety, I changed them all.

I made a simple change to the numguess servlet in the examples directory of my first instance, and using two browser windows, one at localhost:8080 and one at localhost:9080, I can get two separate behaviours in my modified numguess servlet. This is also reflected in the DOS window for that instance. (I modified it to System.out.println the number of guesses... only my modified instance produces this number in the DOS window. Proof, I'm pretty sure, that they represent two JVM's.

You might also consider a 'new' feature of Tomcat 4.0... I haven't read very much on it, and perhaps it's not really what you're trying to accomplish, but check out the document here: %CATALINA_HOME%\webapps\tomcat-docs\RUNNING.txt
and starting at line 104 --> the (4)th point.

This makes reference to CATALINA_BASE for running multiple instances of Tomcat 4.0

[This message has been edited by Mike Curwen (edited October 17, 2001).]
ray bond
Ranch Hand

Joined: Oct 11, 2000
Posts: 111
thanks mike , i changed the ports 8*** to 9*** in second tomcat directory and now there is no "jvm bind err" in console , but how can we be sure that each instace is using separate jvm , i mean my system's default jvm is c:\programfiles\javasoft\jre....,so there is one jvm . do you mean that both tomcat instances are using this jvm but different process space or one instance is using "c:\programfiles\javasoft..." and other "c:\jdk1.3\jre\...", can you please make this jvm issue clear for me.
thanks
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16020
    
  20

Each Tomcat should be running under its own JVM. Please note the difference between the JVM "class" - c:\programfiles\javasoft\jre and instances of that class. A new JVM instance is created in each Windows process group.
Tomcat actually supports running itself in multiple JVMs under a single startup if you get down and dirty with its runtime parameters. By default, however, everything within a single startup runs in the startup's initial JVM, however, since this is both more efficient and more convenient - it's a lot simpler to toss objects around inside a JVM than to bounce them between JVMs/


Customer surveys are for companies who didn't pay proper attention to begin with.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: multiple jvm for tomcat