1. To http://archive.apache.org/dist/tomcat/tomcat-7 download Tomcat source code, this article uses is apache-tomcat-7.0.19-src.zip;
Note: If you download a different version of Tomcat, the version number of the JDK you are using is different. For example apache-tomcat-7.0.19-src.zip use jdk1.6 no problem;
And apache-tomcat-7.0.56 can not be used jdk1.6 need to use jdk1.7, if the use of jdk1.6 code will error, will not find some classes under Java.nio.
2. Create a new Java Project in Eclipse. Named Tomcat7109 (optional).
3. Import all the files from the source code to the newly created project, click the project-right menu->import .... file system->.
4. Use the Conf, Java, test three directories as the source folder.
Right-click on these three folders-->build Path-->use as Source folder;
5. Compile at this time, will error, need to add some necessary jar package.
The required jar packages are:
Ant.jar
Geronimo-spec-jaxrpc-1.1-rc4.jar
Hamcrest-core-1.3.jar
Junit-4.11.jar
Wsdl4j-1.6.2.jar
How to get the jar package:
(1) Download online.
Find out for yourself.
(2) Download the jar package yourself according to Build.properties.default in the source code.
Download Geronimo-spec-jaxrpc-1.1-rc4.jar as An example: Open build.properties.default
Find #---- -Webservices-jax RPC-----
JAXRPC-LIB.VERSION=1.1-RC4
jaxrpc-lib.home=${base.path}/jaxrpc-${jaxrpc-lib.version}
jaxrpc-lib.loc=${base-maven.loc}/geronimo-spec/geronimo-spec-jaxrpc/${ Jaxrpc-lib.version}/geronimo- Spec-jaxrpc-${jaxrpc-lib.version}.jar
Span style= "White-space:pre" > jaxrpc-lib.jar=${jaxrpc-lib.home}/geronimo-spec-jaxrpc-${jaxrpc-lib.version }.jar
Send the address to connect. Base-maven.loc=http://repo.maven.apache.org/maven2
The project structure is for example:
Find the Org.apache.catalina.startup.Bootstrap class and execute it to start Tomcat.
Attention:
When executing the Tomcat source code, assume that Java.lang.ClassNotFoundException:listeners is encountered. Contextlistener error, delete WebApps under the examples folder is available.
Documentation:
http://blog.csdn.net/fwwdn/article/details/8773001
http://my.oschina.net/xpbug/blog/53610
Execute Tomcat source code in eclipse