Trouble Deploying your JSP Web App?

Overview: If your web app works locally, but it will not work after publishing with the regular publishing instructions, you should be able to publish it using these instructions in which you:

·  Test your local project carefully to be sure everything works. “Clean and Build” your local project to ensure all files are deleted and just the right ones recreated locally.

·  Modify your remote logon script so that you can telnet directly into cis-linux2 (not be redirected to a load balancing server),

·  Delete everything from your remote web root folder,

·  Use secure FTP to move the war file up to your web root folder on cis-linux2, then

·  Use secure telnet (remote login, command line prompt) and expand the war file on the server.

Typically, this technique is needed after students have published many ".class" files to the wrong folders and they are trying to fix things.

1.  Thoroughly test your project locally to be sure that everything works. Delete any unused code and test again.

2.  Right click the project name (from the NetBeans project pane on the left side) and select “Clean and Build”. This creates a war file (Web Application Archive file) in the "dist" folder under your project folder. The name of the war file is XXX.war, where XXX is your project's name (and project’s folder name under folder ”NetBeans Projects”). A war file is like a zip file – it contains all the files and folders that you need to deploy your project (compressed into a single file).

3.  Check to be sure that you have a copy of web.xml saved locally (you will need this later). You should have a copy saved on your remote web root folder under the WEB-INF folder. I suggest you store a copy of web.xml under “My Documents/NetBeans Projects” on your local machine so that you can always find it.

4.  Disable Load Balancing (on cis-linux2). Because the CIS department uses load balancing servers, when you try to telnet into cis-linux2, you typically find yourself looking at the command line prompt from a load balancing server. To do what we need to do, we need to be able to log directly onto cis-linux2 (not use a load balancing server). To disable your load balancing, edit your start up script using (or other telnet software), to connect to cis-linux2. When you get to the command line (unix) prompt (from a load balancing server):

·  Invoke vi (or any unix editor of your choice):

vi ~/.cshrc edit your startup script using the vi unix editor

use arrow keys to position the cursor down to the bottom left of the startup script,

just to the left of this line of code:

[ "$tty" != "" ] & [ $HOSTNAME = 'cis-linux2' ] & exec gotoclient

i type "i" which means enter the insert mode

# type # at the beginning of the following line, to comment it out:

#[ "$tty" != "" ] & [ $HOSTNAME = 'cis-linux2' ] & exec gotoclient

<esc> (key) Get out of input mode.

:wq write (save) the file and quit

·  Log out of your telnet / unix session by typing “exit”.

·  Telnet back into cis-linux2 and, this time (and always in the future) you should see the cis-linux2 command line prompt (not any load balancing server like client01…)

·  cd (change directory) to your remote web root folder: /var/lib/tomcat7/webapps/… tux12345

·  Delete everything from your remote web root folder. You can use these unix commands:

o  ls show all the files in the current directory

o  cd dirName change directory to the directory name

o  cd .. change directory to parent directory

o  rm * delete all files from the current directory

o  rm -r dirName delete a directory and everything in it


5.  Still in Secure Shell Client (telnet), delete everything from your web root folder on linux2. To do this, you could type unix commands like this (to navigate to your web root folder):

cd /var/lib/tomcat7/webapps (cd stands for Change Directory, cd .. goes up to the parent level)

cd SP18_3344_tua12345 (but use your NetAccess username instead of tua12345)

ls (you should see all the files from your remote web root folder)

To delete everything from your web root folder on linux2, you can use this very powerful command:

rm -rf folderName (removes a folder and all its contents, recursively)

Or you can use this even more powerful command:

rm -rf * (removes ALL folders and their content, recursively)

6.  Using (or other ftp software), securely ftp the war file from the "dist" folder under your project folder (on your local machine), to your web root folder on cis-linux2: /var/lib/tomcat7/webapps/…tua12345

7.  Back in Secure Shell Client (telnet), extract the war file (into your remote web root folder) by typing this into the command line (a war file is like a unix zip file):

jar -xf xxx.war (where xxxx is the name of your war file, same as your local project folder name).

8.  Back in Secure File Transfer Client , securely ftp the web.xml file (that you had saved on your local machine under “My Documents/NetBeans Project”) up to the WEB-INF folder (underneath your web root folder) on the web server.

9.  Test your web page from a browser. If this did not fix your problem, email your instructor and set up a time to do this together.

1