I want to learn tomcat internal operations and understand the flow.
For this, I created a servlet -
public class TestServlet extends HttpServlet {
I included the tomcat source code in the search source directories and started the server in debug mode. Below is the stack trace when the debugger stops at my breakpoint -
Daemon Thread [localhost-startStop-1] (Suspended (entry into method <init> in TestServlet)) owns: StandardWrapper (id=39) owns: StandardContext (id=40) TestServlet.<init>() line: 12 NativeConstructorAccessorImpl.newInstance0(Constructor, Object[]) line: not available [native method] NativeConstructorAccessorImpl.newInstance(Object[]) line: 39 DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 27 Constructor<T>.newInstance(Object...) line: 513 Class<T>.newInstance0() line: 355 Class<T>.newInstance() line: 308 DefaultInstanceManager.newInstance(String) line: 138 StandardWrapper.loadServlet() line: 1144 StandardWrapper.load() line: 1088 StandardContext.loadOnStartup(Container[]) line: 5123 StandardContext.startInternal() line: 5407 StandardContext(LifecycleBase).start() line: 150 ContainerBase$StartChild.call() line: 1559 ContainerBase$StartChild.call() line: 1549 FutureTask$Sync.innerRun() line: 303 FutureTask<V>.run() line: 138 ThreadPoolExecutor$Worker.runTask(Runnable) line: 886 ThreadPoolExecutor$Worker.run() line: 908 Thread.run() line: 662
As you can see, tomcat initiates a new daemon thread to handle TestServlet initialization. If I exit this position, it will return to its original position, and then stop. However, I want to understand the basic logic of the server. What needs to be done to go to the org.apache.catalina.startup.Bootstrap class? (or some other class that runs in the main launch thread)
source share