Modified from tomcat CS639 setup notes ram@cs.umb.edu

We will be using Linux system sf08.cs.umb.edu for tomcat. Note that it uses the bash shell, not the C shell, marked by the $ prompt, not %.

MOST IMPORTANT:

1. How to find out whether you have a Linux tomcat running:

a. After logging in on sf08.cs.umb.edu, use ps -aux |grep <your username> to see what you have running (even "daemons" like tomcat).  For example, I would use:
$  ps aux | grep eoneil | grep java
I have this command wrapped in a "ckjava" alias--see tomcat.bash

Note: If you see a prompt with %, you're on the wrong system!

b. Use netstat -a to see whether the machine you are on has ports active at the port numbers that were assigned to you.

2. Emergency stop of a tomcat you have started:

Normally, just use "shutdown.sh", using the shutdown script in tomcat's bin.
If this doesn’t work, kill any java processes running with you as owner: kill <pid>.

Setup instructions.

See the Tomcat user's guide for more details.

Tomcat is controlled by a configuration file named server.xml. A standard Tomcat hierarchy has these subdirectories, which you will duplicate in a subdirectory named tomcat6.0 under your course homeword directory, cs639.

directory

content

content of interest

bin

executables

startup.sh, shutdown.sh

conf

configuration files

server.xml, context.xml

lib

libraries

none  (driver jars are here, already)

logs

logs

various

webapps

where your apps go

More detail below

work

a working directory

none

1. Set up your shell and environment for sf08

Copy the provided tomcat.bash from /data/htdocs/cs639/tomcat.bash to your login directory. 
Edit it to use your own database username/passwords. 
If you don't have a .profile file in your login directory, copy ~eoneil/.profile to your login directory.
If you already have a .profile file in your login directory, add one line ". tomcat.bash" to the end of your .profile.  See ~eoneil/.profile for an example.    
Log out and in again to check everything. 
Use "env" to check that CATALINA_HOME and ORACLE_USER, etc. are properly defined.
Note that Java and ant are available: try javac -version and ant -version to check versions: at least 1.6 for Java, 1.6.5 for ant.

2. Set up a tomcat hierarchy

         cd cs639
        rm -r tomcat-6.0  (if redoing this)
    unzip $cs639/tomcat.zip         ($cs639 should expand to /data/htdocs/cs639)
    mv tomcat tomcat-6.0
    cd tomcat-6.0/bin
    chmod +x *.sh    
        make sure scripts are executable


 edit conf/server.xml to change port="8080" to port="xxxxx", your port, and port="8005" to port="yyyyy" where yyyyy is just one more than xxxxx. Note that 8005 comes first in the file.
  edit conf/context.xml to use your username and password for Oracle, MySql. Also change the Oracle URL to the one with port 1521 shown in a comment.

This should result in a tomcat-6.0 hierarchy in your course homework directory.  The two top-level directories you'll work in are conf (a little, as described above) and webapps which where all your applications go.  You may also have occasion to look in the logs directory. When you start building web applications, you need to understand the structure of a webapps context subdirectory and how the result is addressed. In general, for an application named, say, myApp, you will establish a directory webapps/myApp, and will be able to address this as http://sf08.cs.umb.edu:<port>/myApp where <port> is the port you will be assigned.See below.

Create tomcat-6.0/webapps/cs639/index.html to your taste, but make it identify you.  You can see mine at http://sf08.cs.umb.edu:11600/cs639

DO NOT CHANGE PERMISSIONS ON ANYTHING SET UP BY THIS PROCEDURE.

3. Test it all

A. On sf08, use startup.sh to start your tomcat.

B. In a browser, access http://sf08.cs.umb.edu:NNNNN where NNNNN is the first of the port numbers assigned to you. (The second is for tomcat's internal use). It's the one that you changed from 8080 in server.xml.
You should see tomcat's distribution home page, including links to samples.

C. Next try http://<machine>.cs.umb.edu:NNNNN/cs639. You should see the simple cs639 home page that you tailored.

D. Note that the little webapp “servlet1” is installed in webapps. Try it out at tomcat local path /servlet1/servlet/HelloWorld

E. SHUT DOWN TOMCAT. DON'T LEAVE A RUNNING TOMCAT WHEN YOU ARE LOGGED OFF.  Use shutdown.sh.