What's new in Tomcat 8?Debian Jessie was released with Apache Tomcat 8, which provides the following:
- Java Servlet 3.1, an incremental release of the servlet specification that includes non-blocking I/O to improve scaleability and an HTTP protocol upgrade mechanism that allows the client and the server to negotiate a transition from HTTP 1.1 to some other new chosen protocol;
- JavaServer Pages 2.3, a maintenance release to provide support for Expression Language (EL) 3.0 and to use the functionality of the Servlet 3.1 API;
- Java Unified Expression Language (EL) 3.0, which allows EL to run in a standalone mode outside of servlets or JSPs, plus lambda expressions and other Java 8 goodies;
- WebSocket 1.1, which allows full duplex communications over TCP so that bidirectional data can flow at the same time;
- A single, common resources implementation that merges Aliases, VirtualLoader, VirtualDirContext, JAR resources and external repositories into a single framework rather than a separate one for each feature;
- and Java EE 7 as a minimum pre-requisite, preferably Java EE 8, which has better support for HTML5, WebSockets, JSON and RESTful services.
Tomcat 8 is more flexible and better equipped to support web services than its predecessor, so let's proceed to the upgrade.
Installing Tomcat 8Installing Tomcat 8 on Debian Jessie is dead simple. First, SSH to your web server (called 'my-server-IP' here) as root, and execute 'java -version' to check that OpenJDK 7 is installed as a minimum:
If you don't see OpenJDK 7, you will have to install it and set it to be the default JVM:
If you prefer, you can install OpenJDK 8 from the jessie-backports repository instead of OpenJDK 7, but it makes no difference to Tomcat 8.
Now install Tomcat 8:
If all goes well, the service should start automatically and you should be able to browse to http://my-server-IP:8080 to see the default page:
Configuring Tomcat 8Once you have installed Tomcat 8, you must enable the manager webapp, and you may optionally tune the JVM memory settings.
Edit /etc/tomcat8/tomcat-users.xml to include a manager (called 'my-user' here), with the appropriate roles to use the web console manager:
The manager-gui role has the highest privileges, allowing you to use the web console manager to deploy and undeploy apps, view stats, generate leak detection diagnostics, expire sessions, and so on. The admin-gui role is needed to access the virtual host manager.
Optionally edit the default Tomcat 8 configuration to make sure that JAVA_HOME is correctly set and to tune the performance of the JVM:
Now restart Tomcat 8, using the systemd way of managing services:
and browse to http://my-server-IP:8080/manager.
Login with the username you created in tomcat-users.xml to access the Web Application Manager, an eye-watering horror of mustard and green that we will quickly replace with PSI Probe in Part 2 of this series, a much better-looking web console manager with a raft of extra functionality.
Location of Tomcat 8 directories on DebianNote that the Debian package maintainers have a standard Debian way of doing things so the Tomcat 8 directories may not be where you expect them to be. The relevant locations are:
/etc/default: the initial default settings such as the Tomcat user ID, JAVA_HOME, JVM settings, and so on, are in the file 'tomcat8'.
/etc/tomcat8: the server configuration files are here, including context.xml, server.xml and tomcat-users.xml.
/etc/logrotate.d: the log settings for catalina.out are in the file 'tomcat8'.
/usr/share/tomcat8: this is $CATALINA_HOME, the root of the Tomcat installation, also known as $TOMCAT_HOME. It has startup, shutdown, and other scripts, as well as the Tomcat JARs in $CATALINA_HOME/lib (the original project to develop the servlet engine was called Catalina).
/var/lib/tomcat8: this is $CATALINA_BASE, also known as $TOMCAT_BASE, which holds instance-specific directories for web applications, with the code in $CATALINA_BASE/webapps.
/var/log/tomcat8: all the log files are stored here.
Now stay tuned for the installation of PSI Probe in Part 2.