Departmental Tomcat Service(s)

Some departmental web servers host also host a Tomcat service.

Your system group representative should know if your group has such a Tomcat service.

If your research group does indeed have a Tomcat service, you can have your own Tomcat instance on it in/with which you can deploy your own webapps.

The departmental Tomcat services operate via a web service that uses the Proxy mechanism ... we do not use the mod_jk mechanism ... if that's a problem for you, you are always welcome to elaborate why the Proxy mechanism isn't suitable for your webapp.

A single web server can host several Tomcat services that are each run by a separate account in/from a separate directory. In this way you can deploy your webapps without being influenced by other Tomcat instances on the same web server.

Tomcat Instance Configuration

To get your own Tomcat instance, you need to give us the following data:

  • the web/tomcat server on which you want to start your Tomcat instance
  • a public ssh key with which you want to connect to the web/tomcat server system to configure/start/stop your Tomcat instance
  • a (unique) name for your Tomcat instance ... ask your system group representative if you don't know what would be appropriate
    • In the remainder of this text, this name will be referred to as $NAME
    • Do mind that this name will be visible in the URL on/via which your tomcat-apps must/can be reached (see below, with the Apache Proxy configuration) so pay special attention to it!

You will receive from us the following configuration details:

  • the directory on the web/tomcat server system in which your Tomcat instance is located ... normally this will be something like:
      /localhost/tomcat-apps/$NAME
  • the private port on which your Tomcat instance is listening ... this is of no other importance than initial testing ... once everything is running as expected, you will not need to use that port anymore.

In your Tomcat instance directory, you will initially see 1 sub-directory tomcat containing your Tomcat instance configuration and work-dirs. In your Tomcat instance directory, so alongside that tomcat sub-directory, you can create your own directories as you need and/or see fit ... you can also create additional sub-directories in the tomcat sub-dir, but make sure that you (and your colleagues ;-) can keep apart your own data from the tomcat configuration.

    IMPORTANT: Your Tomcat instance will be executed by the same account that owns your Tomcat instance directory. Everything you put in your instance directory can be changed/overwritten/deleted by your Tomcat instance (by accident or by abuse). If you want to make sure that the things you need for your webapp absolutely cannot be changed by the webapp, you should consider to chown that data to another account and give read- but not write-access to that data to your Tomcat account.

In the tomcat sub-directory there are several sub-dirs that are of importance to you:

  • bin: containing the start and stop script (see below)
  • conf: the Tomcat instance configuration ... know what you are doing before you change something here ... you'll probably also have to restart your instance after changing something here
  • logs: this is where you should look to check if everythings works OK
  • temp and work: this is where Tomcat does its own stuff ... know what you are doing before you change something here
  • webapps: this is were you should copy your .war file(s) to to deploy your tomcat/webapp ... files put here are inspected and started automatically !

Using your own Tomcat instance

  • Login to the web/tomcat server system using the name and ssh key you specified:
      ssh -p 2222 -l $NAME -i your-ssh-key tomcatserver.cs.kuleuven.be

    (as you can see, for most departmental web/tomcat servers you need to connect to the non-standard port 2222)

    Then start your instance using:

      /localhost/tomcat-apps/$NAME/tomcat/bin/startstop.sh start

    The other actions you can use that startstop.sh script for are:

    • /localhost/tomcat-apps/$NAME/tomcat/bin/startstop.sh stop
    • /localhost/tomcat-apps/$NAME/tomcat/bin/startstop.sh restart

    They do of course what they suggest to do ;-)

    Check whether it is started with:

      ps aux | grep $NAME

    You can/should also inspect the log files in:

      /localhost/tomcat-apps/$NAME/tomcat/logs
  • Copy your .war file(s) in:
      /localhost/tomcat-apps/$NAME/tomcat/webapps

    they will be detected and started automatically ... check the log files to see if it is recognized and deployed as expected.

    Also when copying/installing new versions of existing .war file(s) they will be detected and re-deployed automatically.

  • Test it with your private port: use a web browser to connect to:

      http://tomcatserver.cs.kuleuven.be:your-port/your-webapp

    Do mind that this test-connection on your private port will only work from within departmental intranet or via departmental VPN.

Automatic Startup

If everything is working as expected, you can/should ask helpdesk to:

  • add this Tomcat instance to the automatic start/stop configuration:
      # cat /etc/cs-localservices/$NAME
      $NAME /localhost/tomcat-apps/$NAME/tomcat/bin/startstop.sh
    such that it is started/stopped whenever the web/tomcat server system is started/stopped.

Access via Apache Proxy

If you want to access this tomcat instance from outside the departmental intranet and/or without the departmental VPN, you can/should ask helpdesk to:

  • add this Tomcat instance to the web service configuration:
      # cat /etc/apache2/conf.private/httpd.conf
      ProxyPass		/$NAME	http://localhost:your-port/
      ProxyPassReverse	/$NAME	http://localhost:your-port/
    (helpdesk should not forget to reload the configuration with: /etc/init.d/apache2 reload ;-)

After this, you can use your tomcat/webapp from any location where the web server is accessible from using:

    http://tomcatserver.cs.kuleuven.be/$NAME/your-webapp

If you want to use https instead of http, you should ask helpdesk to configure the (Proxy configuration of the) web service accordingly.