Install and debug Tomcat source code (1)

Source: Internet
Author: User

References:

Http://tomcat.apache.org/tomcat-6.0-doc/building.html

Http://blog.csdn.net/huxin1/archive/2008/04/13/2289140.aspx

This installation is based on myeclipse8.0 and jdk1.5. Tomcat source code is managed using subversion. First install the Subversion plug-in.

1. Install the subversionr plug-in

Click Help --> Software Updates --> Add/Remove sofeware --> Add -->

A. Enter the subversion in search and search for the corresponding subversion. Select version 1.6 for installation.

B. Click Add, enter the name you want in name, such as (subversion), enter http://subclipse.tigris.org/update_1.6.x in URL

Next, you can install the Subversion plug-in.

2. Check out the Tomcat Project

Click file --> Import --> SVN --> plug a project from SVN --> Create a new resource library location --> enterBytes

3. Compile Tomcat source code

The Tomcat source code is compiled with ant. Here we will not introduce ant installation. Check the information.

Here, you can use myeclipse to directly run build. XML with ant, or manually run the ant command in the Tomcat project directory.

I am using the latter.

First, some packages must be depended upon during compilation. Ant will download the packages during execution.

There is related information in the build. properties. default file. First, we change build. properties. Default to build. properties,

Find base. path =/usr/share/Java. This path is used to store the directory of the files to be downloaded. Because I use the Windows operating system, this path should be changed. For example, here I use base. path = E:/myeclipse8ga/workspace/tomcat6/share

Then, execute the ant command: ant download

An error may occur when you run this command because some of the build. properties files are invalid.

I encountered this problem during installation, mainly reflected in jdt. Loc = http://www.eclipse.org/downloads/download.php? File =/Eclipse/downloads/drops/R-3.3.1-200709211145/eclipse-JDT-3.3.1.zip

This path is I later replaced, the original address has expired, but I found it download is too slow, so I found an address on the internet, path for http://archive.eclipse.org/eclipse/downloads/drops/R-3.2-200606291905/download. PHP? Dropfileappseclipse-jdt-3.2.zip, but I put this path to base. path does not work, so after downloading it directly, decompress it to E:/myeclipse8ga/workspace/tomcat6/share (ant will decompress the file after downloading it ). Remember to directly decompress the package to the current folder, which is the eclipse folder by default.

The ant download command is successfully executed.

Finally, execute the ant command directly and the compilation is successful. Some APIs may be reported in the middle, but they do not have much impact. Looking at other files, it seems that there may be problems with JDK 1.6, but it is not tested and has no right to speak.

For compilation using myeclipse, right-click build. XML --> Run as --> select the second ant build --> Select Download in target and click Run To start downloading. This may take a long time because jdt has 19 m, then right-click build. XML --> Run as select the first ant build. You can complete the compilation.

The directory structure after the download is completed is as follows:

After compilation, you will find an output directory in the Tomcat project directory. There are two subdirectories: Build and classes. classes is a class bytecode file, the following figure shows the directory after normal tomcat installation.

4. Remove unnecessary classpath references

After completing the previous steps, refresh the Tomcat project in myeclipse and you will find a Red Cross, indicating that an error exists. Right-click the project, select build path --> configue build path from the pop-up menu, delete two library files starting with tomcat_libs, and retain only one JRE library file, click "OK ".

5. Add dependency packages

The Tomcat source file depends on some jar packages. Otherwise, a compilation error is reported.

Ant. Jar (copy it in the Lib subdirectory of the ant installation directory)

Commons-collections-3.1.jar (copy from the commons-collections-3.1 subdirectory just downloaded by ANT)

Commons-dbcp-1.2.1.jar (copy from the commons-dbcp-1.2.1 subdirectory just downloaded by ANT)

Commons-logging-1.1.jar (if you do not have this jar package on your machine, download it from http://commons.apache.org/downloads/download_logging.cgi)

Commons-pool-1.2.jar (copy from the commons-pool-1.2 subdirectory just downloaded by ANT)

Org. Eclipse. jdt. core_3.2.0.v_671.jar (copy from the eclipse \ plugins subdirectory downloaded by ant just now)
6. start Tomcat

Run tomcat in eclipse. Find the main startup class org. Apache. Catalina. startup. Bootstrap of Tomcat, right-click this class, and select "Run as…" in the pop-up menu ..." --> "Open Run dialog ..." In the displayed "run" window, enter the program running parameter "start" and JVM running parameter Catalina. Home, as shown in the following window.


Click Run To start Tomcat.

7. segment debugging

Right-click org. Apache. Catalina. startup. Bootstrap --> debug as --> JAVA application to enable tomcat to start in debug mode,

Find Org. apache. jasper. compiler. compiler class, place a breakpoint in the first line of the generatejava () method, access http: // localhost: 8080/examples/JSP/, and click execute on the page, if the page content remains unchanged, the JSP page will not be re-compiled. Therefore, when you click execute for the first time, myeclipse enters the debug mode, but does not respond when you click execute again.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.