Supplement · Tomcat

Catalina container hierarchy và request routing

Tomcat không chỉ là HTTP server: Catalina quản lifecycle/container, Coyote quản protocol, Jasper compile JSP và các Realm/Valve cung cấp cross-cutting behavior.

Architecture

Hierarchy và ownership

Server là top-level lifecycle; mỗi Service ghép nhiều Connector với một Engine. Engine route virtual host tới Host, rồi context path tới Context; Wrapper đại diện Servlet. Không đặt Context trực tiếp trong server.xml nếu deployment lifecycle cần độc lập.

Request path

Socket/protocol processing ở Coyote tạo request/response facade; Mapper chọn Engine/Host/Context/Wrapper. Valve pipeline chạy ở từng container level trước Filter chain và Servlet. Vì vậy access logging, RemoteIpValve và authentication có scope/order khác Filter của application.

Lifecycle

Các component triển khai init → start → stop → destroy và phát lifecycle events. Resource phải được tạo/đóng theo owner tương ứng. Embedded Tomcat xây cùng object graph bằng Java API; Spring Boot customization không xóa lifecycle semantics.

Failure modes

Sai Host alias/context path gây route nhầm; Valve sai scope/order thay đổi security/audit; shared resource đặt sai owner gây leak hoặc cross-app coupling. Debug bằng effective config, startup logs, mapped host/context và pipeline—not chỉ controller logs.

Architecture Overview · Configuration Reference
← Mục lụcCoyote →