Lab 2: Deploying a Web app

Objective: In this lab, you will configure access to the Manager application that ships with Tomcat, and also deploy a simple web application.

  1. Open the file conf/tomcat-users.xml using a text editor like vi or nano or emacs.
  2. Add the following two entries, which defines a role named manager-gui (which is the expected role name used by the Manager app), and also defines a user named tomcat with a password of password:
    <role rolename="manager-gui"/>
    <user username="tomcat" password="password" roles="manager-gui"/>
  3. Save your changes to tomcat-users.xml.
  4. Open the /webapps/manager/META-INF/context.xml file, which is the deployment config file for the Manager app. It is currently configured to only be accessed from localhost, but you need to access it remotely from your Web browser on your local machine, so delete (or comment out) the RemoteAddrValve. The context file should simply look like:
    <Context antiResourceLocking="false" privileged="true" >
    </Context>
  5. Save your changes to /webapps/manager/META-INF/context.xml.
  6. There is a permission issue that may arise if you already attempted to open the Manager app. Make sure the webapps/manager folder and subfolders are owned by tomcat. If they are currently owned by root, run the following command from your install folder:
    sudo chown -R tomcat:tomcat webapps/manager/
  7. Restart Tomcat:
    service tomcat restart
  8. From your Tomcat home page, click on the button that links to the Manager App:
  9. You will be promted to login. From tomcat-users.xml, your username is tomcat and password is password.
  10. You should see the Tomcat Web Application Manager app. Notice you have 5 application currently deployed:
  11. Now you are going to deploy a web application which is already created and packaged in a WAR file. From within the Manager app, locate the section titled "WAR file to deploy". Click the Choose File button, then browse to and choose the Lab_02/myapp.war file:
  12. Click the Deploy button. If successful, you should see myapp in the list of deployed Applications:
  13. Click on the /myapp link, which will take you to the home page of the app:
  14. Enter a date, and the app will calculate how old you are:


  15. If you enter invalid input, like a string for the month, you should see the error page that is built-in to the app:

Summary: In this lab, you configured access to the Manager application and deployed a simple WAR file. You could have also copied the WAR file into your webapps folder, which is how you would deploy an application if you are not using or do not have access to the Manager app.