7 Feb

Tomcat installation and setup notes


A good link to use – https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04 However, this installs Tomcat for public exposure.

I chose to install it in my personal account. The primary reason was to put it in a non-sudo directory so it would be easier to work with.  It is running on my personal laptop with no other users. Another reason was I wanted to easily run my Servlet in my local directory for testing and mirroring sites that might use them.

The structure I’m using:


tomcat* (this entire tomcat install)

‘site n’-webapps

‘site n’-docBase

Steps I used

  1. I did create a tomcat group – sudo groupadd tomcat
  2. I did not create a tomcat user and assign its directory above as `useradd` will not create a user using tomcat8
  3. I created private structure – mkdir tomcat ; mkdir tomcat/tomcat8
  4. I installed tomcat into tomcat8 – tar xzvf Downloads/apache-tomcat-8.5.27.tar.gz -C /home/roye/tomcat/tomcat8 –strip-components=1
  5. I changed  the group – chgrp -R tomcat tomcat8
  6. I changed – chmod -R g+r conf  ;  chmod -R g+x conf

Website Structure

docBase    WEB-INF        web.xml  <- configures which servlets are used, welcome pages, security 
                 issues        classes  <- a directory containing the servlets and supporting classes. 
                 This is a root classes must be locate below by their package name
                 e.g. com.cnrepperson.test.TestClass.class
    static_content  <- html, php and other content not associated with the site's
                    configuration or servlets

 Setting up Tomcat for remote debugging using Eclipse

Summarized from https://confluence.sakaiproject.org/display/BOOT/Setting+Up+Tomcat+For+Remote+Debugging

We recommend adding this stuff to your startup script so that you are always running tomcat in debug mode.

  1. Open the startup script in (your_tomcat_home)/bin/startup.sh
  2. Add the following lines at the first blank line in the file (around line 8)
    export JPDA_ADDRESS=8000
    export JPDA_TRANSPORT=dt_socket
  3. Change the execute line at the end to include jpda start
    exec "$PRGDIR"/"$EXECUTABLE" jpda start "$@"
  4. Run the startup script when starting tomcat to run tomcat in debug mode

Setup up Eclipse

copied from http://starredmediasoft.com/tomcat-configure-remote-debugging/ on eclipse do the following steps:

  1. Select project to debug
  2. Choose “Debug configurations..” on Debug menu
  3. On “Remote Java Application” left menu, click “New Launch Configuration” button
  4. On Connection Type, select “Standard (Socket Attach)” combo item
  5. Type on the listening port (on the above tomcat configuration, was 8000)
  6. Click on Debug and start listening