Import the Tomcat source into eclipse

Source: Internet
Author: User
Tags tomcat server

Objective:

After writing the original version of the socket small application, there are a lot of expected features in the middle of the implementation, in the process of writing also found a lot of problems. Because the front has a rough look at the tomcat implementation of the principle of parsing, know that Tomcat is also a pure Java written Web server, but also with the socket communication. So in particular, I want to see how Tomcat handles these problems.

Main steps:

1. Go to Apache official website to download the corresponding Tomcat version of the source code (i download here is 9.0.0.m9) http://tomcat.apache.org/download-90.cgi

2. The extracted source code is not able to be directly imported into eclipse as a project. You need to use ant to compile, so you need to download the ant version on the ant website. http://ant.apache.org/bindownload.cgi

Then configure Ant_home, Path, classpath.

3. Open the console with the root path of the extracted Tomcat source, and enter the ant ide-eclipse to compile. The next heap of dependent jar packages is now. The path to which these jar packages are downloaded can be specified by opening the Base.path in the Build.properties.default file with the path, and the default value is ${user.home}/tomcat-build-libs. In fact, under the C:\Users\Administrator\tomcat-build-libs path. Here, in order to put the downloaded dependent jar package into the Tomcat source path, modify Base.path to E:/sourcecode/code/tomcat/apache-tomcat-9.0.0.m9-src/build-libs.

4. If you are using the latest version of the Tomcat source code, it may appear during compilation: [Get] Error getting https://objenesis.googlecode.com/files/ Objenesis-1.2-bin.zip's error. This is obviously caused by the celestial firewall. I will download here to upload to the following Baidu Cloud address: Http://pan.baidu.com/s/1c2oO0so. After the download is complete, we can modify the file to be local and modify the format as follows:

#-----objenesis, used by EasyMock, version 1.2 or later-----
objenesis.version=1.2
Objenesis.home=${base.path}/objenesis-${objenesis.version}
Objenesis.loc=http://localhost:8080/objenesis-${objenesis.version}-bin.zip
Objenesis.jar=${objenesis.home}/objenesis-${objenesis.version}.jar

This specifies that the file is local. We simply put the downloaded jar package into the local Tomcat Webapps/root directory and start the Tomcat server. Of course, the easier way, we can actually delete this section to execute the process, and then the download to the ZIP package directly to the previous re-specified Base.path path. This will find a objenesis-1.2 directory with 3 jar packages under the directory.

Finally, we just need to re-execute the ant ide-eclipse again and make sure the build success.

5. Import the corresponding project source and path in Eclipse, and you can see that eclipse can now import it as a project. Import in general there will also be a compilation error. The 3 build path settings need to be considered at this time:

One is the version of the JRE and the Java compile version

The second is the Ant_home setting: specific steps such as

The third is to set Tomcat_libs_base, the steps above, the last path chosen is the path of the Base.path configuration.

6. Clean the entire project in eclipse and it should be possible to compile successfully. Then find the Bootstrap.java class, run as a Java program. After successful operation, it can be accessed by: http://localhost:8080/.

At this point, it is possible to analyze the tomcat process progressively by using Debug.

Import the Tomcat source into eclipse

Related Article

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.