Tomcat (Lucky Number) 7 - Beta Drops
Tomcat (Lucky Number) 7 - Beta Drops
Join the DZone community and get the full member experience.Join For Free
Atomist automates your software deliver experience. It's how modern teams deliver modern software.
The Apache Software Foundation says that Tomcat has been downloaded over ten million times in its long history. As the Java platform moves forward, so too must Tomcat, and version 7 implements many specs that were finalized with Java EE 6 in December (the integrated Eclipse compiler has also been updated). Security and performance enhancements have also been added. The Manager and Host Manager web applications now have new authorization roles and unique URLs. A URL button on the manager (http://localhost:8080/manager/html/findleaks) activates an analysis of memory usage and helps with the troublesome memory leaks that were a big issue for some Tomcat users.
In DZone's earlier interviews with Tomcat committer and Senior SpringSource Software Engineer Mark Thomas, he explained some of the major benefits we'd see in Tomcat 7. First, he explained the benefits of Servlet 3.0:
- The benefits of an asynchronous style of programming (scalability, async request/response) are already available to Tomcat users in Tomcat 6. The async support in the Servlet 3 spec provides a standard interface that will provide portability between containers.
- Increased control over session tracking, in particular the ability to use the SSL session ID to track user sessions which provides additional security.
- Use of generics throughout the Servlet 3 API allows programming errors to be detected at compile time rather than run time as well as enabling the writing of cleaner code.
- File upload support will enable Tomcat users to use file upload functionality within their web applications with the need for additional libraries.
In an interview specifically about memory leaks, Thomas explained that Tomcat had fixed all of the known memory leak-related bugs in Tomcat and he described some of the work-arounds that Tomcat 7 would have for the bugs in various web apps, libraries, and the JVM:
For the application or library code problems, Tomcat fixes problems where it can by de-registrating the object(s) that were registered by the application or library. Tomcat will also log any action taken so the web application developer can fix the root cause of the problem, rather than relying on Tomcat to fix the leak. This is especially important for threads that are not stopped since Tomcat can not do this safely.
The details of how Tomcat fixes these problems may be found in the clearReferences() method of the WebappClassLoader class.
For the Java API usages that can trigger a memory leak, these are all triggered if the first call to that API is made by a web application. Tomcat, therefore, prevents these leaks by ensuring that the core Tomcat code is the first to call these APIs, thereby making them safe for web applications to call.
The details of this protection can be in the JreLeakPreventionListener class.
The one exception to this is the java.util.logging Implementation (JULI). The logging framework provided by the JRE is not class loader aware and can quickly lead to memory leaks in a Servlet container environment. To address this, JULI replaces the standard LogManager with one that is class loader aware. This allows java.util.logging to be used without triggering a memory leak.
Refactored Tomcat 7 code has provided MBean registration, Jasper integration, enhanced life-cycle managers, connectors, and better security. One overlooked new feature is the improved support for embedding Tomcat. Tomcat 7 provides a simple API and a download option that offers all the Tomcat features but with a fewer number of JARs. Another key feature is logging improvements. Thomas said, "These include a asynchronous file handler that writes the logs to disk in a separate thread so request processing threads do not suffer the associated delay if they have to write the log messages to disk and a single line log formatter that outputs Tomcat log messages on a single line rather than two lines which makes the log files easier to work with for administrators." Finally, Tomcat will be able to tighten or relax its enforcement of specifications based on user needs.
Tomcat 7 is backwards compatible with the last two versions. Download Tomcat 7 Beta 1 here.
Opinions expressed by DZone contributors are their own.