O'Reilly logo

Professional Apache Tomcat 6 by Jeff Genender, Sing Li, Vivek Chopra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Class Loaders

Every Java developer makes extensive use of class loaders, often without realizing it. Each time a class is instantiated as an object or referenced statically, that class must be loaded by the Java Virtual Machine (JVM) into memory. Thus, even statements as simple as String greeting = "hello" or int maxValue = Integer.MAX_VALUE make use of a class loader. They require the String class and the Integer class to be loaded, respectively.

While class loaders are designed to operate fairly transparently from the developer's point of view, there are subtleties to their use that are important to understand. Why a chapter on class loading in a Tomcat book? It turns out that class loaders and their behavior are a big part of Tomcat. Following the Servlet specification, Tomcat is required to allocate a unique class loader to each Web application. This chapter explains what this means and why it is important.

Following an explanation of class loaders in general and Tomcat's class loaders in particular, we discuss common problems related to class loaders. By the end of this chapter, not only will you be familiar with class loaders in general, but you'll also understand how they relate specifically to Tomcat.

The following topics are covered in this chapter:

  • An overview of class loaders

  • Security issues with class loaders

  • Tomcat and class loaders

  • Dynamic class reloading

  • Common class-loader issues

Class Loader Overview

Java was designed to be platform-independent and to support distributed ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required