Original address: http://denger.iteye.com/blog/834121
Recently, some of the mechanism of Tomcat has attracted interest, so download the source code to DEBUG to find out ~
Tomcat_6_0_18.zip Bag: Http://pan.baidu.com/s/1mgGcPug
Download the extracted directory structure:
It's obviously built on ANT, directly through
Java Project form Existing Ant buildfile, Eclipse, New, directly selects the build.xml file below tomcat_6_0_18,
Then the target in the listed task selects complie to import the project.
Not yet finished, his compilation also relies on four jar files, respectively:
Ant.jar, Jaxrpc.jar, Org.eclipse.jdt.core_3.8.3.v20130121-145325.jar, Wsdl4j-1.5.1.jar, these four jar files need to be brought in.
OK, next, add a appliction that launches Tomcat directly in the Debug configurations in eclipse.
Specifically, add the main startup item to Java application and select the Tomcat 6.0 project ( actual name Bootstrap) that you just imported.
Main class fills in the org.apache.catalina.startup.Bootstrap startup class,
Arguments:
In program arguments fill in start ,
In VM arguments, fill in the path to the Tomcat home ( source path ), such as:-dcatalina.home= "E:\tomcat-src\TOMCAT_6_0_18".
As shown in the following:
After configuration, direct Apply and Debug, this time the direct start will appear the following exception:--- This paragraph I did not test
Java code
- Java.lang.ClassNotFoundException:listeners. Contextlistener
- At Org.apache.catalina.loader.WebappClassLoader.loadClass (Webappclassloader.java:1645)
- At Org.apache.catalina.loader.WebappClassLoader.loadClass (Webappclassloader.java:1491)
The reason is that there is a example webapp in Tomcat in WebApps, which is configured with the listeners in the app's Web. Xml. Contextlistener, and this class does not exist in its classpath. The solution is to remove the example directly, but it does not affect debug anyway.
Now that the TOMCAT deployment has been completed, the next step is to start the debug ....
Debugging Tomcat6 Source (go) under Eclipse