How to step into tomcat source?

You can debug Tomcat as a remote Java application.

Here is the steps:

  1. Create a Java project and copy Tomcat source files into project's source folder. (You can ignore compile errors.)
  2. Open Bootstrap.java and set a breakpoint at main method.
  3. Create a CATALINA_BASE/bin/setenv.bat(or .sh) file and put following line into the file.

    set JPDA_OPTS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=y

  4. Start the Tomcat in debug mode using catalina.bat (or .sh) from command line.

    catalina.bat jpda start

  5. From Eclipse, set up a Debug Configuration under Remote Java Application and connect to the Tomcat process. (Run -> Debug Configurations -> Remote Java Application.)

Screenshot: Tomcat debugging using JPDA_OPTS