Application for creating a user friendly web interface for R scripts

 


Instructions for installing Tomcat

Install Java

Tomcat needs Java installed. If your machine does not already have Java then you will need to install it. You will want to install the latest version of Java which at the time of writing is Java 2 Software Development Kit, Standard Edition (J2SE SDK) version 5.0 Update 7. This can be found at http://java.sun.com/javase/downloads/index.jsp and follow the link to download 'JDK 5.0 Update 7' where you can select and download the appropriate version for your machine. Instructions for installing the download can then be found at http://java.sun.com/j2se/1.5.0/install.html.

Set environment variable JAVA_HOME

The environment variable JAVA_HOME needs to be set to the pathname of the directory where you installed the JDK. On Windows XP you can do this from 'Control Panel' -> 'System' -> 'Advanced' -> 'Environment Variables' -> 'System Variables' -> 'New'. Then in 'Variable name' type JAVA_HOME and in 'Variable value' type the correct path eg C:\j2sdk1.5.0 then Click 'OK'
In Linux (bash shell) you can set the environment variable in your startup file '.bash_profile' by including a line such as `export JAVA_HOME=/usr/local/bin/jdk1.5.0_03' or whatever the correct path is on your system.

Install Tomcat

You probably want to download the binary distribution. The latest version at the time of writing is Tomcat 5.5.
Tomcat can be downloaded at http://tomcat.apache.org/ and follow the link to 'Download, Tomcat 5.x' to the left of the page. You will want the 'Core' distribution, and will want either a zip or tar.gz for Linux or the Windows executable depending on your operating system.
Installation of the binary on both Linux and Windows is then entirely straight forward.
On Linux uncompress the download into a convenient location so that the distribution resides in an directory conventionally named "jakarta-tomcat-5".
On Windows just run the .exe file you have downloaded. However one important point to note when installing Tomcat on a Windows machine - when the installer asks into which directory Tomcat should be installed don't install into the default directory, install into a directory called, for example, C:\tomcat\tomcat-5-5. The reason for this is that the default choice will have spaces in the path which will cause major problems when running applications.

Starting Tomcat

Tomcat can be started by executing the following commands:
$CATALINA_HOME\bin\startup.bat (Windows)
$CATALINA_HOME/bin/startup.sh (Unix) (remember to make executable permissions i.e "chmod +x startup.sh")
where $CATALINA_HOME is the full path name to Tomcat's directory eg. C:\tomcat\tomcat-5-5 on Windows or /home/software/jakarta-tomcat-5 on Linux. You can set the environment variable CATALINA_HOME in the same way that you set JAVA_HOME in the section above.
In Windows XP Tomcat can also be started and stopped from 'Start' -> 'Control Panel' -> 'Administrative Tools' -> 'Services' -> 'Apache Tomcat'

Stopping Tomcat

Tomcat can be shut down by executing the following command:
$CATALINA_HOME\bin\shutdown (Windows)
$CATALINA_HOME/bin/shutdown.sh (Unix)

Using Tomcat

After startup, the default web application included with Tomcat 5 will be available by visiting: http://localhost:8080/
Your own web applications can be deployed by copying the .war file to $CATALINA_HOME/webapps
For example if you have a web application myapp.war, copy this file to $CATALINA_HOME/webapps and myapp can then be accessed at http://localhost:8080/myapp
To access myapp over the internet your machine will need an internet name or IP address, in which case the URL will be as above but with 'localhost' replaced by the machine's internet name or IP address.

Troubleshooting

There are 3 things that may go wrong during a stand-alone Tomcat 5 install:
  1. Another web server or process may have already claimed port 8080, the default HTTP port that Tomcat attempts to bind to at startup. To change this, edit file: $CATALINA_HOME/conf/server.xml
    Search for '8080' and change it to a port that isn't in use, and is greater than 1024 (because ports less than or equal to 1024 require superuser access to bind under UNIX). Then restart Tomcat and if, for example, you changed the port to 1977, the URL to access applications will now be http://localhost:1977/.
  2. "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. '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.

Further information

Hopefully this article will contain all the information you need to get Tomcat up and running, but if not then the Tomcat website http://tomcat.apache.org/ contains full documentation and useful FAQs. Another good site with lots of further information is Tomcat 5 on Linux Step-By-Step. One issue that may arise is the need to provide access to your Apache Tomcat server using port 8080, through an Apache HTTP server using port 80, which may be the only port to the exterior permitted by your network's firewall. Information on how to do this can be found at the above two sites and at Using Apache HTTP with Apache Tomcat