How to Tomcat 5, Part 2


How do we install one Tomcat server to share it between many users?

After default (with default parameters offered by an installation program) installation of Tomcat for single user you get such directory structure under $CATALINA_HOME directory:




bin - contains startup and binary files
common - contains all the external libraries which are used by Tomcat (not Tomcat classes here, look for them at server directory)
common/classes
common/endorsed
common/i18n
common/lib
conf - all major configuration files are here
logs - here you find "famous" catalina.out log file and saved previous catalina.out and more logs, like manager.log, admin.log, host-manager.log
server - here are Tomcat class files, packed in jar files and plus configuration files for host-manager and manager. Who are them? Read later
shared - here shared classes should be
temp - place for some temp things... Do not know exactly what it is. On my machine I see bugzilla37035-safeToDelete.tmp file with 0 bytes length here.
webapps - place where your web applications are/will be.
work - here Tomcat will place class files after the compilation. As you probably know, Tomcat "compiles" first JSP pages into servlet java code and then compiles those servlets into class files. That's why Tomcat named servlet container, not JSP container :-)

Now, when you got an overview on Tomcat structure, we are ready to go further.

Tomcat has the variable $CATALINA_BASE which is in case of single user is equal to $CATALINA_HOME. Just add the argument "-Dcatalina.base=$CATALINA_BASE" to startup file and $CATALINA_BASE variable must contain files for 'personal' Tomcat instance.

As you can probably assume Tomcat sharing between multiple users requires that every user have own configuration and own applications.

Usage of this argument will force Tomcat to use relative references for files in the following directories based on the value of $CATALINA_BASE instead of $CATALINA_HOME:

conf - Server configuration files (including server.xml)
logs - Log and output files
shared - For classes and resources that must be shared across all web applications
webapps - Automatically loaded web applications
work - Temporary working directories for web applications
temp - Directory used by the JVM for temporary files (java.io.tmpdir)

Finally you get what you need to get a freedom and feel free from other guys :-)
If you do not pass the "-Dcatalina.base=$CATALINA_BASE" argument to the startup command, $CATALINA_BASE will be default to the same value as $CATALINA_HOME, which means that the same directory is used for all relative path resolutions.

For troubleshooting of Tomcat server installation please look at Troubleshooting section below:

The administration and manager web applications, which are defined in the $CATALINA_BASE/conf/Catalina/localhost/admin.xml

and

$CATALINA_BASE/conf/Catalina/localhost/manager.xml files, will not run in that configuration, unless either:

- The path specified in the docBase attribute of the Context element is made absolute, and replaced respectively by $CATALINA_HOME/server/webapps/admin and $CATALINA_HOME/server/webapps/manager
- Both web applications are copied or moved to $CATALINA_BASE, and the path specified in the docBase attribute of the Context element is modified appropriately.
- Both web applications are disabled by removing $CATALINA_BASE/conf/Catalina/localhost/admin.xml

and

$CATALINA_BASE/conf/Catalina/localhost/manager.xml

Troubleshooting section

There are only 3 things likely to go wrong during a stand-alone Tomcat installation:

(1) The most common hiccup is when another web server (or any process for that matter) has laid claim to port 8080. This is the default HTTP port that Tomcat attempts to bind to at startup. To change this, open the file:

$CATALINA_HOME/conf/server.xml

and search for '8080'. Change it to a port that isn't in use, and is greater than 1024, as ports less than or equal to 1024 require superuser access to bind under UNIX.

Restart Tomcat and you're in business. Be sure that you replace the "8080" in the URL you're using to access Tomcat. For example, if you change the port to 1977, you would request the URL http://localhost:1977/ in your browser. Remember, that all URLs (pointing to your pages, for example from one to another) that are used in application also must have a port number in every URL to work properly, including forms if they post towards your server. It is good idea to move that port to web.xml file as a parameter which is read during start up of your application. Web xml is default configuration file which is used by every application on Tomcat. You can find it under webbaps/yourapplicationpath/WEB-INF directory.

(2) An "out of environment space" error when running the batch files in Windows 95, 98, or ME operating systems.
Right-click on the STARTUP.BAT and SHUTDOWN.BAT files. Click on "Properties", then on the "Memory" tab. For the "Initial environment" field, enter in something like 4096.
After you click apply, Windows will create shortcuts which you can use to start and stop the container.

(3) The 'localhost' machine isn't found. This could happen if you're behind a proxy. If that's the case, make sure the proxy configuration for your browser knows that you shouldn't be going through the proxy to access the "localhost".

In Netscape, this is under Edit/Preferences - Advanced/Proxies, and in Internet Explorer, Tools - Internet Options - Connections - LAN Settings.
In Internet Explorer here: Tools - internet Options - Connections - LAN Settings.
In Firefox: Tools - Options - General - Connection Settings

Alexandre Patchine publishes Java Programming Tips on JavaFAQ.nu site and offers free "1000 Java Tips" e-book on his site. You can find many free Java books and Java tools on his site. If you are learning Java the JavaFAQ.nu is best place to start with.

Close    To Top
  • Prev Article-Personal Tech:
  • Next Article-Personal Tech:
  • Now: Tutorial for Web and Software Design > Personal Tech > Software > Personal Tech Content
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Geek Tutorial
     

    Blogging Tutorial

      RSS Tutorial
      Podcasting Tutorial
    Graphic Design Tutorial
      Coreldraw Tutorial
      Illustrator Tutorial
      3D Tutorials
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial/ Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial/ Articles
     

    XML Style

      AJAX Tutorial
      XML Mobile
    Flash Tutorial/ Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial/ Articles
      Linux Tutorial
      Symbian Tutorial
      MacOS Tutorial
    Personal Tech
      Hardware Tutorial
      Software Tutorial
      Online Auction