The following article will guide you through the new Tomcat 8 Web server release, showing what’s new with that release and which are the required steps for upgrading to Tomcat 8.
The first important change, is that Tomcat 8 requires now Java 7 or later in order to run, therefore if you are migrating from earlier Tomcat version, you should upgrade to Java 7. (bet you should anyway upgrade to Java 7 since Java 6 reached the EOL 🙂 )
In terms of specification, Apache Tomcat 8 supports the newer Java EE 7 specification for the Web profile that is Java Servlet 3.1, JavaServer Pages 2.3, Java Unified Expression Language 3.0 and, most interesting one, supports the Java WebSocket 1.0 specifications as defined by JSR-356.
In terms of the server connectors, the default HTTP and AJP connector implementation has switched from the Java blocking IO implementation (BIO) to the Java non-blocking IO implementation (NIO). The older BIO may still be used but Servlet 3.1 and WebSocket 1.0 features that use non-blocking IO will then fallback to blocking IO instead which may cause unexpected application behavior.
Additionally, Tomcat 8 can use the Apache Portable Runtime to provide superior scalability, performance, and better integration with native server technologies. The Apache Portable Runtime is a highly portable library that is at the heart of Apache HTTP Server 2.x. APR has many uses, including access to advanced IO functionality (such as sendfile, epoll and OpenSSL), OS level functionality (random number generation, system status, etc), and native process handling (shared memory, NT pipes and Unix sockets).
When APR or the Java NIO API is enabled Tomcat 8 is able to use Comet support to allow servlets to process IO asynchronously, receiving events when data is available for reading on the connection (rather than always using a blocking read), and writing data back on connections asynchronously (most likely responding to some event raised from some other source).
Web application resources
The Resources element that is part of the configuration and represents all the resources available to the web application has been revised. Now it includes classes, JAR files, HTML, JSPs and any other files that contribute to the web application. Implementations are provided to use directories, JAR files and WARs as the source of these resources and the resources implementation may be extended to provide support for files stored in other forms such as in a database or a versioned repository.
When starting Tomcat 8 with the jpda option to enable remote debugging, Tomcat 8 listens on localhost:8000 by default. Earlier versions listened on *:8000. If required, this default can be overridden by setting the JPDA_ADDRESS environment variable in, for example, setenv.[bat|sh].
Changes in API
Whilst the Tomcat 8 internal API is broadly compatible with Tomcat 7 there have been many changes at the detail level and they are not binary compatible. Developers of custom components that interact with Tomcat’s internals should review the JavaDoc for the relevant API.
Of particular note are:
- The Manager, Loader and Resources have moved from Container to Context since Context is the only place they are used.
- The Mapper has moved from the Connector to the Service since the Mapper is identical for all Connectors of a given Service.
- There is a new Resources implementation,as we said, that merges Aliases, VirtualLoader, VirtualDirContext, JAR resources and external repositories into a single framework rather than a separate one for each feature.