[AI Readability Summary]
Tomcat is the core runtime container for Java web applications. Its key value lies in using Connectors to handle protocol communication, Containers to manage the Servlet lifecycle, and layered architecture plus class loader isolation to solve multi-application deployment, request routing, and extensibility challenges. Keywords: Tomcat architecture, Catalina, class loaders.
The technical specification snapshot summarizes Tomcat’s core characteristics
| Parameter | Description |
|---|---|
| Primary language | Java |
| Core protocols | HTTP/1.1, AJP, Servlet specification |
| Project type | Web server + Servlet container |
| Architecture model | Connector-Container dual-layer model |
| Core components | Server, Service, Engine, Host, Context, Wrapper |
| Lifecycle | The Lifecycle interface drives init/start/stop/destroy |
| Key mechanisms | Pipeline-Valve, JMX, ClassLoader isolation |
| Stars | Not provided in the source |
| Core dependencies | Catalina, Coyote, Jasper, Servlet/JSP API |
Tomcat is essentially an extensible Servlet container
Tomcat started with Catalina as its core and later added JSP, EL, Naming, and related capabilities. As a result, it is not just a container that “executes Servlets,” but a complete Java web runtime.
A Servlet does not have a main method. It must run inside a container. Tomcat’s job is to receive requests, construct Request/Response objects, invoke the target Servlet, and return the result to the browser.
public interface Servlet {
void service(ServletRequest req, ServletResponse res);
// Core logic: the container invokes the service method to drive business execution
}
This code shows that a Servlet does not run on its own. A container such as Tomcat hosts and schedules it.
Tomcat uses a layered and nested component architecture
Tomcat’s core structure can be summarized as Server → Service → Connector + Engine → Host → Context → Wrapper. In this model, the Connector handles network protocols, while the Container handles business dispatching and Servlet management.

AI Visual Insight: This diagram shows Tomcat’s nested container hierarchy. The top-level Server manages multiple Service instances. Each Service binds protocol entry points through Connector to the request-processing core Engine, which then routes requests layer by layer through Host, Context, and Wrapper. This reflects Tomcat’s design principle of decoupling network communication from application execution.
Each layer has a clearly defined responsibility
Server: The top-level management unit for the entire Tomcat instance.Service: Groups one or moreConnectorinstances with a singleEngineinto a service unit.Engine: The request dispatch hub inside a Service.Host: Represents a virtual host.Context: Represents a web application.Wrapper: Wraps a single Servlet.
<Server port="8005" shutdown="SHUTDOWN">
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1" />
<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="webapps" />
</Engine>
</Service>
</Server>
This configuration directly maps to Tomcat’s component hierarchy and provides the most reliable entry point for understanding the source code.
An HTTP request travels down the container chain step by step
When a request such as http://localhost:8080/test/index.jsp arrives, the Connector first receives and parses the protocol, then hands the request to the Engine within its owning Service. Tomcat then matches Host, Context, and Wrapper in sequence, ultimately locating the target Servlet or JSP engine.
In essence, this process is a three-stage pipeline: protocol parsing, container routing, and Servlet invocation. That is why Tomcat acts as both a network server and an application container.
The chain of responsibility and lifecycle model work together as key mechanisms
Tomcat does not simply call components directly. Instead, it uses Lifecycle to manage initialization, startup, shutdown, and destruction in a unified way, uses Pipeline-Valve to form a pluggable processing chain, and exposes management interfaces through JMX.
Registry.getRegistry(null, null).invoke(mbeans, "init", false);
Registry.getRegistry(null, null).invoke(mbeans, "start", false);
// Core logic: trigger component initialization and startup through JMX
This code reflects Tomcat’s engineered approach to component management rather than a loose collection of object calls.
Bootstrap is the real entry point of the Tomcat startup chain
Tomcat startup begins at the main method of org.apache.catalina.startup.Bootstrap. It first initializes class loaders, then reflectively loads Catalina, and finally delegates the real assembly and startup work to it.
Class<?> startupClass = catalinaLoader.loadClass("org.apache.catalina.startup.Catalina");
Object startupInstance = startupClass.getConstructor().newInstance();
// Core logic: load Catalina through a dedicated class loader
catalinaDaemon = startupInstance;
This code shows that Bootstrap acts more like a launcher, while Catalina is the core startup coordinator of the Tomcat runtime.
Tomcat’s class loading design exists to support multi-application isolation
Tomcat does not fully follow the traditional parent delegation model because it must run multiple web applications in the same process while avoiding dependency conflicts. If two applications depend on different versions of a library with the same class names, forced sharing would immediately cause class pollution.
Bootstrap typically involves three loaders: commonLoader, catalinaLoader, and sharedLoader. In many versions, default configuration may cause them to point to the same parent loader in practice, but they still serve different roles by design.
commonLoader = createClassLoader("common", null);
catalinaLoader = createClassLoader("server", commonLoader);
sharedLoader = createClassLoader("shared", commonLoader);
// Core logic: build Tomcat's internal class loader hierarchy
The key point in this code is not the API itself, but the isolation boundary: Tomcat’s own classes, libraries shared by all applications, and libraries private to a single application must remain controllable.

AI Visual Insight: This diagram presents the official class loader hierarchy and emphasizes that relationships among Common, Catalina, Shared, and each WebApp ClassLoader are not simple linear inheritance. Instead, they define access boundaries around container visibility and application isolation. This is the key visual model for explaining how Tomcat can run multiple applications at the same time while avoiding JAR conflicts.
WebAppClassLoader is created dynamically during application startup
The default Context implementation, StandardContext, checks for and creates a WebappLoader during startup. That means each web application gets its own class loading space, which enables independent hot deployment and version isolation.
if (getLoader() == null) {
WebappLoader webappLoader = new WebappLoader(getParentClassLoader());
// Core logic: create a private loader for the current web application
setLoader(webappLoader);
}
This code shows that the class loader is not just a JVM accessory. It is a core facility in Tomcat’s application isolation model.
Catalina’s load process completes Server instance assembly
After Bootstrap calls Catalina.load(), Catalina parses command-line arguments, initializes Naming, reads server.xml, and then creates and initializes the Server object.
public void load() {
initNaming();
parseServerXml(true); // Core logic: parse server.xml and assemble the component tree
getServer().init(); // Core logic: trigger top-level Server initialization
}
You can treat this code as the master switch for the first half of Tomcat startup: configuration becomes objects, and objects enter the lifecycle.

AI Visual Insight: This flowchart shows the key action sequence in Catalina’s load phase: initialize the naming environment, parse server.xml, create the Server and its child components, redirect output streams, and then trigger lifecycle initialization. It shows that Tomcat startup is not a one-shot start, but a two-phase model that separates assembly from execution.
Catalina’s start process drives Server into the running state
After load() completes, Catalina.start() calls getServer().start(). That propagates lifecycle events down through Service, Connector, Engine, and each container layer.
At the same time, Tomcat registers a JVM Shutdown Hook so that when the process exits, it can call stop() and destroy() for orderly cleanup instead of terminating abruptly.
getServer().start();
Runtime.getRuntime().addShutdownHook(shutdownHook);
// Core logic: start the server and register a graceful shutdown hook
This code shows that Tomcat startup means more than opening a listening port. It also includes complete resource lifecycle governance.
Understanding Tomcat starts with four main threads
First, understand the component tree: Server/Service/Engine/Host/Context/Wrapper. Second, understand the request path from Connector to the target Servlet. Third, understand class loader isolation, which is the foundation of multi-application deployment. Fourth, understand the lifecycle model, which is the main axis for reading the source code.
Once these four threads connect, Tomcat source code stops looking like a pile of isolated classes and becomes a highly modular container system with stable responsibilities and a clear execution chain.
The FAQ section answers the most common structural questions
Are Tomcat and Catalina the same thing?
No. Catalina is Tomcat’s core Servlet container and startup framework. On top of Catalina, Tomcat also integrates JSP, Naming, connectors, and other capabilities required for a complete web runtime.
Why does Tomcat not fully adopt parent delegation?
Because it must host multiple web applications at the same time. If every application shares the same class loading path, different dependency versions will pollute one another and cause runtime conflicts.
Which source code entry points are most important to trace during Tomcat startup?
Start with Bootstrap.main(), Bootstrap.init(), Catalina.load(), and Catalina.start(). These four entry points connect class loading, configuration parsing, component assembly, and lifecycle startup.
Core summary: This article reconstructs Tomcat’s essential concepts from both source code and configuration perspectives. It explains the Connector-Container dual-layer model, the hierarchy from Server to Wrapper, the class loader isolation mechanism, and the full startup chain from Bootstrap to Catalina and then to Server. It is ideal for Java developers who want a systematic understanding of Tomcat architecture, startup flow, and class loading principles.