SWE 642 Servlet Deployment Instructions

9-Feb-2009
Update 30-Oct-2009
Update 23-Aug-2013
Please tell me if you find any errors or omissions in the document. -JO

The software engineering group has collaborated with VSE's computing support staff to provide an application server for servlets and JSPs (apps-swe642) for you to use as your "target deployment computer". This server supports J2EE with the open-source platform Tomcat. The server is called apps-swe642 and is part of the Hermes Cluster. I will use the name apps-swe642 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-swe642. The server is behind the VSE 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 one of the VSE computer labs in the Engineering building.

If you are using the computer lab, the steps are straightforward and you can skip to the "Deploy and Test" section.



Connecting to apps-swe642

To access the server and deploy your code from outside the firewall, you need to follow these steps:

  1. Review the information provided about the VPN tool from http://labs.vse.gmu.edu/index.php/Services/VPN.
  2. Follow the "Setup Instructions" to install the VPN tool on your computer. (This will not take long.) If your browser hesitates to go to the VPN download page because of security ertificate issues, it's okay. Simply tell your browser to accept the certificate VSE uses (CACERT).
  3. Run the VPN tool as described in the instuctions. You 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 VSE fire wall.
  4. Connect to the apps-swe642.vse.gmu.edu server using SSH or SFTP.
  5. For a complete walkthrough of setting up OpenVPN (and SSH) on Windows XP go to http://labs.vse.gmu.edu/index.php/FAQ/FAQ
  6. Please Note: If you disconnect the VPN tool, or the connection times out, your SSH or SFTP session will be lost. Therefore SAVE YOUR WORK OFTEN.
  7. Note that your password on apps-swe642 is the same as your GMU email password.


Deploy and Test Servlet

Now that you are connected to the server, you can deploy and test your code. The server can accept both WAR and .class files. The rest of these instructions assume you are deploying a simple .class file. To deploy your servlet, follow these steps:

  1. 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.
  2. Make a directory for your Java class package under /data/swe642fall2013/swe642/WEB-INF/classes.
  3. Use the SSH Secure File Transfer Client (sftp) to copy your .class files from your computer to the folder you just created on apps-swe642.
  4. Test your servlet using the following URL:
  5. NOTE: make sure that your files are readable.


Deploying War Files (advanced)

J2EE applications can also be deployed as "WAR" files. A Java WAR file contains a compressed directory structure that mirrors the directory structrure in a servlet context. That is, it contains a WEB-INF/classes/, web.xml/, etc. WAR files (with the extension .war) are placed in the top level tomcat directory (/data/swe642fall2013/ on apps-swe642). When tomcat sees the WAR file, it unpacks the file into a directory, which becomes a new context.

So, if we deploy a WAR file called HelloWorld.war, with a hello.jsp file contained at the root of the directory, then the URL would be http://apps-swe642.vse.gmu.edu:8080/HelloWorld/hello.jsp.

WAR stands for Web Application Archives. WAR files can be created in three ways:



Additional Notes

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
Back to schedule page