File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes How to setup the same application (multiple instances) running on different ports under Tomcat 6.0.x Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How to setup the same application (multiple instances) running on different ports under Tomcat 6.0.x" Watch "How to setup the same application (multiple instances) running on different ports under Tomcat 6.0.x" New topic
Author

How to setup the same application (multiple instances) running on different ports under Tomcat 6.0.x

achal patel
Greenhorn

Joined: Dec 16, 2009
Posts: 5
All,

Below is the requirement:

I have installed Tomcat 6.0.x and have running application i.e. http://localhost:8080/myapp with it.
Have created a context file <Tomcat>\conf\catalina\localhost\myapp.xml for the same.

Now wanted to run the same application (separate instance) having same context root as 'myapp' under the same Tomcat instance but on a different port #.
i.e. http://localhost:8088/myapp

Which is similar to what Weblogic has as domains for such requirements. Can you please help me on this?

Thanks,
Achal.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

It's probably actually more efficient to run multiple instances of the app in a single Tomcat with different context names, then use a proxy to route to them. However, there are cases where what you want are valid as well. I helped set up a 16-node cluster where each machine had 4 CPU cores and they wanted a separate Tomcat for each core.

The key here is to understand the difference between CATALINA_HOME and CATALINA_BASE. One of them refers to the sharable parts of a Tomcat server, and the other refers to the per-instance parts, including the server.xml file that defines which ports a given Tomcat instance will be serving.

Note that you can't just reassign port "8080". Tomcat typically runs 4 or 5 ports for things like control, https, tunneling, and so forth. Since only one program can own a port, you have to provide alternate ports for these services as well.


Customer surveys are for companies who didn't pay proper attention to begin with.
achal patel
Greenhorn

Joined: Dec 16, 2009
Posts: 5
Thanks Tim.

#1 currently we are using different context name with a single Tomcat to achieve the same but wanted to evaluate the possibilities to simulate what is working in Weblogic instance.

Can you point me to the docs having details on Shared and per-instance resources under Tomcat to see if I can make use to achieve mentioned scenario.

Thanks,
Achal.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

Well, I'm not totally clear on that. Even in WebLogic, I haven't found it beneficial to have a WebLogic server to be responding on multiple HTTP ports.

As a general rule, sharable resources are going to be defined in the TOMCAT_HOME/conf/server.xml file and per-instance resource are defined in the individual webapp's context definitions. Beyond that, I'd have to have a better idea of that the ultimate goal is in high-level terms.
achal patel
Greenhorn

Joined: Dec 16, 2009
Posts: 5
The idea here is to bring up multiple instances of the application on different ports during the development or training activity in order not to man-handle application context.

With WebLogic, this can be achieved by creating multiple domains using Configuration wizard and providing different ports for each domain.
Now using multiple domain (running on different port), the same application instances can be deployed without sharing any resources, having same context roots.

This also helps in showing differences in the features between older version of application with newer version for business guys who might not be well-versed with application server skills.

All they would do is to create another domain in WebLogic providing different port and showcase features etc and I wanted to achieve the same using Tomcat Server considering the lightweight memory requirement of Tomcat Server.

Hope this helps.

Thanks,
Achal
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
achal patel wrote:This also helps in showing differences in the features between older version of application with newer version for business guys who might not be well-versed with application server skills.


For any person, it would be more human readable to have something like www.coderanch.com/forums_old and www.coderanch.com/forums_new, instead of www.coderanch.com:8080/forums and www.coderanch.com:8081/forums
achal patel
Greenhorn

Joined: Dec 16, 2009
Posts: 5
For any person, it would be more human readable to have something like www.coderanch.com/forums_old and www.coderanch.com/forums_new, instead of www.coderanch.com:8080/forums and www.coderanch.com:8081/forums


Is it even possible to achieve www.coderanch.com:8080/forums and www.coderanch.com:8081/forums using Tomcat?

Thanks,
Achal.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

achal patel wrote:
For any person, it would be more human readable to have something like www.coderanch.com/forums_old and www.coderanch.com/forums_new, instead of www.coderanch.com:8080/forums and www.coderanch.com:8081/forums


Is it even possible to achieve www.coderanch.com:8080/forums and www.coderanch.com:8081/forums using Tomcat?

Thanks,
Achal.


Yes it is. It's just generally not considered to be worth the effort. A new context is trivially easy to set up and as a side benefit it is visually more obvious than a new port number to people looking at URLs (or worse, reporting them over the phone).

If your context name is hard-coded in the webapp, you've got bigger problems than just the port numbers.
achal patel
Greenhorn

Joined: Dec 16, 2009
Posts: 5
I agree with you Tim but we have few flex based components which uses context root and right now there is no easy way to dynamically change the context root, as it's configured in the flex configuration file.

What you have mentioned having different context roots, was the first approach I took to validate and it worked for me.

Thanks,
Achal.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

achal patel wrote:I agree with you Tim but we have few flex based components which uses context root and right now there is no easy way to dynamically change the context root, as it's configured in the flex configuration file.

What you have mentioned having different context roots, was the first approach I took to validate and it worked for me.

Thanks,
Achal.


Hmmm. Applets have had this problem as well. The usual solution is to have the server insert a parameter into the applet declaration as it displays the page with the applet object reference in it. Can Flex handle that?

As a quick fix, I'd recommend just running a separate Tomcat with alternate ports defined in server.xml. Unlike WebLogic, you don't have to pay for a second license, the extra overhead is pretty low, and it would probably take less than an hour to get going.
bee Darole
Greenhorn

Joined: Apr 24, 2011
Posts: 3
Was this achieved... ???
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to setup the same application (multiple instances) running on different ports under Tomcat 6.0.x