Http://www.cnblogs.com/huangfox/archive/2011/10/20/2218970.html
1.Tomcat Source Download
Apache-tomcat-6.0.41-src.zip
2.ant installation, for compiling Tomcat's source code.
apache-ant-1.8.4
3.ide--Choose Eclipse3.7.
=================================
First step:
Extract the Tomcat source, such as decompression to E:\study\tomcat\apache-tomcat-6.0.41-src.
Step Two:
2.1 Using ant to compile Tomcat source, you need to download dependent items before compiling. We don't know what dependencies we need to compile and what to do.
Let Ant help you out. We just need to prepare a place to store these dependencies, such as D:\tomcat\basepath.
2.2 To get ant to work, we'll also rename the Build.properties.default in the Apache-tomcat-6.0.41-src folder to Build.properties,
and open it, modify the Base.path=e:/study/tomcat/basepath.
2.3 Download Dependent items, enter command console, enter directory E:\study\tomcat\apache-tomcat-6.0.41-src, execute command:ant download.
2.4 After the download of the dependent items, you can compile tomcat. Execute command:ant. When the compilation is complete, we can view the directory E:\study\tomcat\apache-tomcat-6.0.41-src,
You can find a folder with one more:output.
The output folder is structured as follows:
We will find that this structure is consistent with the tomcat structure extracted from the installation package.
Into the bin, start Tomcat success, it means that--ant compiled Tomcat succeeded.
=====================================
Import Tomcat source into eclipse.
First step:
Create a new Java project in Eclipse, for example: Tomcat6.
Step Two:
Import->file system
Select the tomcat source in from directory, choose Java and Test (test if you need it), and the following figure:
Select the Tomcat6,finish we just created in into folder.
Note: Set Java, test to Source Folder,java build path->source->add folder...-> select Java and test.
The project structure is now shown in the following illustration:
Part III: Import JAR packs.
The red forks above are because of the lack of jars, we need those jar packs now.
Test needs Junit.jar, which is directly in eclipse.
Required in Java: Ant.jar jaxrpc.jar Org.eclipse.jdt.core_3.3.1.v_780_r33x.jar Wsdl4j-1.5.1.jar
Ant.jar is available under the apache-ant-1.8.4 directory.
Jaxrpc.jar
http://download.csdn.net/download/vincentlyf/4992240
(Java APIs for xml-based Remote Procedure call,jax-rpc) converts XML types to Java types to ensure a smooth exchange of data between Web service clients and java-based applications.
Org.eclipse.jdt.core_3.5.2.v_981_r35x.jar
http://download.csdn.net/download/fan008boy/2652497
Wsdl4j-1.5.1.jar http://download.csdn.net/download/ttnuli/5459539
After the import will be refreshing.
Fourth Step:
Start Tomcat in Eclipse.
Find class: Bootstrap class in Org.apache.catalina.startup package.
Run as: Set in arguments VM arguments
-dcatalina.home= "D:\output\build"
And then it's ready to start.
Note:e:\study\tomcat\apache-tomcat-6.0.41-src\output\build under the Lib, conf, WebApps Copy to D:\output\build
==========================================
question:
Why to set-dcatalina.home= "D:\output\build".
Let's start by explaining what output is-it's an ant-compiled output folder that you can try to delete to see if it can be started successfully.
What happens if you don't configure this parameter? Delete-dcatalina.home= "D:\output\build", Error:
2011-10-20 14:49:35 org.apache.catalina.startup.ClassLoaderFactory Validatefile
Warning: Problem with directory [D:\myWorkSpace\tomcat6\lib], exists: [false], isdirectory: [false], CanRead: [FALSE]
2011-10-20 14:49:35 org.apache.catalina.startup.ClassLoaderFactory Validatefile
Warning: Problem with directory [D:\myWorkSpace\tomcat6\lib], exists: [false], isdirectory: [false], CanRead: [FALSE]
2011-10-20 14:49:35 Org.apache.catalina.startup.Catalina Load
Warning: Can ' t load server.xml from D:\myWorkSpace\tomcat6\conf\server.xml
2011-10-20 14:49:35 Org.apache.catalina.startup.Catalina Load
Warning: Can ' t load server.xml from D:\myWorkSpace\tomcat6\conf\server.xml
2011-10-20 14:49:35 Org.apache.catalina.startup.Catalina Start
Serious: Cannot start server. The Server instance is not configured.
You can see from the root of the project there is no Lib folder, no Conf folder, there is no server.xml in conf, so can not instantiate the server.
Then follow his cue to do it, and at the start it's OK.