Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Catalina base

 
Bartender
Posts: 1752
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a step by step how to set up Tomcat so it will have multiple start-stop instances?

I've looked through my tomcat 7 books, but there's nothing understanable or even barely discussed.

A tutorial would be nice.

Thanks in advance,

- mike
 
Saloon Keeper
Posts: 22289
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat has 2 types of constituent components: shareable components and per-instance components.

The default single-instance Tomcat has both types of components within a single directory tree, which I usually refer to as TOMCAT_HOME, since I can never remember the difference between CATALINA_HOME and CATALINA_BASE. This is purely laziness on my part, as there's nothing officially named "TOMCAT_HOME".

Fortunately, I know where to look it up when I need to.

CATALINA_HOME refers to the shareable components. They include the lib and bin(?) directories.

CATALINA_BASE refers to the per-instance components. They include conf, work, temp, log, and webapps. The reason I put a question mark next to "bin" under CATALINA_HOME is because there's one non-shared file under bin, which is the setenv.sh/setenv.bat file. Reading between the lines in the RUNNING.txt file under my "TOMCAT_HOME", I get the impression that Tomcat may overlay the CATALINA_BASE bin directory over the CATALINA_HOME bin directory, making them effectively the same directory. But I'm not 100% certain.

In the simple case of a single Tomcat, CATALINA_HOME and CATALINA_BASE both reference the same directory ("TOMCAT_HOME"). If you set one, before launching Tomcat, the other one will inherit the same value.

If, however, you want to run multiple Tomcats off the same binaries/libs, you'd clone the Tomcat directory and delete the bin and lib subdirectories, then launch the cloned Tomcat with CATALINA_HOME pointing to the original Tomcat directories and CATALINA_BASE pointing to the cloned directories, which you would have configured with its own CATALINA_BASE/conf/server.xml file and webapp deployments (in CATALINA_BASE/webapps or via CATALINA_BASE/conf/Catalina/localhost or both). You would DEFINITELY have to have a different server.xml, since Tomcat, like all programs that listen on TCP/IP ports can only have one Tomcat instance listening on a given port set.

So, for example, you might have Tomcat 1 using CATALINA_BASE=CATALINA_HOME using the out-of-the-box ports (8080, 8005, 8009, 8443) and its deployed webapps. Then you might have Tomcat 2 using a different CATALINA_BASE whose server.xml was set for ports 8180, 8185, 8109 and 8543. The actual choices for port numbers is up to you as long as no other app is using them AND as long as the port number is 4096 or higher (since in most OS's, ports 0-4095 can only be acquired by privileged users).

Other than that, the only constraint is that all Tomcat instances sharing the same CATALINA_HOME are going to be running the exact same version of Tomcat. If you wanted to run a Tomcat 6.0.28, 6.0.34, and 7.0.41, there would be 3 CATALINA_HOME settings, one for each of the 3 versions of Tomcat. Or you might for some reason want to have 2 physical copies of the 7.0.41 release in 2 separate directories, and each of them would require a distinct CATALINA_HOME, since CATALINA_HOME is what points to the specific set of shared binary files.
 
Mike London
Bartender
Posts: 1752
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's an amazingly good explanation. I understand this better now.

However, I'm still looking for a step by step tutorial so I can actually follow and do it so I can see exactly what I need to change in this file, that file, how I might set up this and that, -- at least to set up a couple Tomcat directories (one cloned).

Thanks,

- mike
 
Tim Holloway
Saloon Keeper
Posts: 22289
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A) Clone the Tomcat directory

B) Edit the cloned TOMCAT_HOME/server.xml file to use an alternative set of ports that don't conflict with any other services on that machine (including the original Tomcat)

C) Start the cloned tomcat with CATALINA_HOME set to point to the original copy of Tomcat and CATALINA_BASE set to point to the cloned Tomcat.

Deploy apps, etc. in the usual way.
 
Mike London
Bartender
Posts: 1752
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:A) Clone the Tomcat directory

B) Edit the cloned TOMCAT_HOME/server.xml file to use an alternative set of ports that don't conflict with any other services on that machine (including the original Tomcat)

C) Start the cloned tomcat with CATALINA_HOME set to point to the original copy of Tomcat and CATALINA_BASE set to point to the cloned Tomcat.

Deploy apps, etc. in the usual way.



Thanks Tim. I'll give this a try. Really doesn't sound difficult.

Appreciate your follow up.

JR is the best!

- mike
 
Tim Holloway
Saloon Keeper
Posts: 22289
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not difficult.

Debugging Camel OSGi has proven difficult - the stupid test frameworks don't pull in all the necessary bundles and behave in different ways depending on whether they're run from command-line or IDE. But multiple Tomcat's aren't difficult at all!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic