SWE 432 Servlet Deployment Instructions
10/27/2008
Please tell me if you find any errors or omissions in the document.
-JO
The ISE department provides an application server
for servlets and JSPs (apps-swe432),
and you should use apps-swe432 as your "target deployment computer".
This server supports J2SE with the open-source platform Tomcat.
The server is called apps-swe432
and is part of the Hermes Cluster.
I will use the name apps-swe432 in the course and in this page.
This page presents step-by-step instructions to deploy your Servlets
and JSPs to the Tomcat application server on apps-swe432.
The server is behind the IT&E fire wall.
Therefore, you will need to use the Virtual Private Network (VPN) application
to access it from outside the off-campus.
Or, you can access it directly in the Computer Lab in the IT&E lab in S&T II room 137.
If you are using the computer lab,
the steps are straightforward and you can skip to the "Deploy and Test" section.
Connecting to apps-swe432
To access the server and deploy your code from outside the firewall,
you need to follow these steps:
- Review the information provided about the VPN tool from
https://access.ite.gmu.edu/vpn/.
- Follow the "Setup Instructions" to install the VPN tool on your computer.
(This takes about 5 minutes.)
- Run the VPN tool as described in the instuctions.
Yuu will need your GMU email username and password.
Once connected,
your computer will be given an IP address that will connect it to the network
within the IT&E fire wall.
- Connect to the apps-swe432.ite.gmu.edu server using SSH or SCP.
- For a complete walkthrough of setting up OpenVPN (and SSH) on Windows XP go to
http://labs.ite.gmu.edu/reference/ITE-vpn.html
- Please Note: If you disconnect the VPN tool,
or the connection times out, your SSH or SCP session will be lost.
Therefore SAVE YOUR WORK OFTEN.
Deploy and Test Servlet
Now that you are connected to the server,
you can deploy and test your code.
The server can accept many different formats, including WAR and .class.
The rest of these instructions assume you are deploying a simple .class file.
To deploy your Servlet, follow these steps:
- Write your servlet to belong to a package belonging to your GMU username.
For example, I would add the command:
package offutt;
to my servlet.
When compiling with javac, you will need to compile from "above" the directory:
javac offutt/Hello.java.
- Make a directory for your Java class package under
/apps/tomcat/swe432/WEB-INF/classes.
Note: Use your GMU username as a name for the package.
- For example: mkdir /apps/tomcat/swe432/WEB-INF/classes/offutt
- Use the SSH Secure File Transfer Client (sftP)
to copy your class files to the folder you just created.
- Note: You can also use sftp to place the file into your home directory on
apps-swe432, then use the Unix copy command (cp) to copy the file
to the deployment directory through an ssh window on aps-swe432.
- Test your servlet using the following URL:
- NOTE: make sure that your files are readable.
- To make your files readable, run the Unix command on apps-swe432: chmod 644 *
Additional Notes
-
All 432 students have to put our servlets in the same directory.
Therefore we will
(1) create package subdirectories for our servlets based on our user names,
or
(2) use the convention of prefacing our Java servlet classes with our user names.
So, my servlet would be "X"
and is accessed within my package directory with the "dot" notation,
"offutt.X",
or my servlet would be "offuttX".
-
To compile on apps-swe432,
you will need to set your CLASSPATH variable.
CLASSPATH=$CLASSPATH:.:/usr/local/tomcat/common/lib/servlet-api.jar
-
Tomcat keeps its log files in the directory:
/var/tomcat/logs/.
The files "catalina.out" and
"apps_access_log.2007-MM-DD.txt"
accumulate log entries from Tomcat.
("MM" is a 2-digit indicator of the month and
"DD" is a 2-digit indicator of the day.)
You can sometimes look here to find error messages from your servlets.
NOTE, never ever do this:
try
{
... ...
} catch(Exception e){
System.out.println(e.getMessage());
System.exit(0);
}
The servlet is running inside Tomcat, so this will cause Tomcat to exit.
All of your classmates will be very angry!
References