1. To http://archive.apache.org/dist/tomcat/tomcat-7 download the Tomcat source code, this article uses is the Apache-tomcat-7.0.19-src.zip;
Note: If you download a different version of Tomcat, you are using a different version of the JDK. 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;
4. conf, Java, test three folders as the source folder.
Right-click on these three directories-->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 the 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
Project structure such as:
Find the Org.apache.catalina.startup.Bootstrap class and run to start Tomcat.
Attention:
When running Tomcat source code, if you encounter java.lang.ClassNotFoundException:listeners. Contextlistener error, delete the examples directory under WebApps.
Reference files:
http://blog.csdn.net/fwwdn/article/details/8773001
http://my.oschina.net/xpbug/blog/53610
Running Tomcat source in eclipse