How to import Tomcat source code into idea

How to import Tomcat source code into idea

1. Download the tomcat code

This article chooses the 9.0 branch. This version of the servlet is still on github starting with javax

2. Directory structure after downloading

insert image description here

3. The source code is built using ant (pom is used here instead)

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.apache.tomcat</groupId>
  <artifactId>tomcat</artifactId>
  <name>tomcat</name>
  <version>9.0.19</version>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant</artifactId>
      <version>1.10.11</version>
    </dependency>
    <dependency>
      <groupId>wsdl4j</groupId>
      <artifactId>wsdl4j</artifactId>
      <version>1.6.3</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/javax.xml.soap/javax.xml.soap-api -->
    <dependency>
      <groupId>javax.xml.soap</groupId>
      <artifactId>javax.xml.soap-api</artifactId>
      <version>1.4.0</version>
    </dependency>

    <dependency>
      <groupId>org.apache.geronimo.specs</groupId>
      <artifactId>geronimo-jaxrpc_1.1_spec</artifactId>
      <version>2.1</version>
    </dependency>

    <dependency>
      <groupId>org.eclipse.jdt</groupId>
      <artifactId>ecj</artifactId>
      <version>3.17.0</version>
    </dependency>


    <dependency>
      <groupId>org.easymock</groupId>
      <artifactId>easymock</artifactId>
      <version>4.0.2</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>biz.aQute.bnd</groupId>
      <artifactId>biz.aQute.bndlib</artifactId>
      <version>5.2.0</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>com.unboundid</groupId>
      <artifactId>unboundid-ldapsdk</artifactId>
      <version>3.2.0</version>
    </dependency>
  </dependencies>

</project>

Use idea to re-import directly, and temporarily select jdk 1.8

4. Problem Solving

4.1 Console garbled characters

INFO: At least one JAR was scanned for TLD but does not yet contain the TLD. Enable debug logging for this logger to obtain the full list of JARs that were scanned but in which no TLDs were found. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
September 29, 2021 3:52:17 AM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
WARNING: Creating SecureRandom instance for session ID generation using [SHA1PRNG] took [149] milliseconds.

September 29, 2021 3:52:17 Garbled Modify the encoding of conf/logging.properties (now defaults to utf-8, basically no changes) Warning: Using [SHA1PRNG] to create a SecureRandom instance for session ID generation took [149] milliseconds Garbled

The essential reason for the garbled characters here is that the properties file is garbled. Tomcat uses the system's way of reading configuration files, using URL.openStream, and then using the properties.load method, which will cause garbled characters.

Solution

Read and rewrite the two internationalization files Localizer and StringManager

4.2 Access 8080 and report an error: jsp and other classes cannot be found

Add a line of code to the org.apache.catalina.startup.ContextConfig#configureStart method //TODO manually added context.addServletContainerInitializer(new JasperInitializer(), null); 

insert image description here

5. Visit localhost:8080

insert image description here

over

Note that if there are other compilation options, jdk11-16 can directly comment out other errors and solve them normally.

This is the end of this article about importing Tomcat source code into idea. For more relevant content about importing Tomcat source code into idea, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to start source code debugging of tomcat in Idea and enter into tomcat for debugging
  • Detailed explanation of IDEA creation Tomcat8 source code project process

<<:  About using Alibaba's iconfont vector icon in Vue

>>:  Web page image optimization tools and usage tips sharing

Recommend

Essential bonus items for optimizing and packaging the front end of Vue projects

Table of contents Preface 1. Routing lazy loading...

Steps to install superset under win10 system

Superset is a lightweight self-service BI framewo...

Vuex implements a simple shopping cart

This article example shares the specific code of ...

Nginx stream configuration proxy (Nginx TCP/UDP load balancing)

Prelude We all know that nginx is an excellent re...

Weird and interesting Docker commands you may not know

Intro Introduces and collects some simple and pra...

How to quickly use mysqlreplicate to build MySQL master-slave

Introduction The mysql-utilities toolset is a col...

Detailed installation and configuration tutorial of PostgreSQL 11 under CentOS7

1. Official website address The official website ...

The difference between ${param} and #{param} in MySQL

The parameter passed by ${param} will be treated ...

Example code for implementing dynamic column filtering in vue+element table

Requirement: When displaying data in a list, ther...

Do not start CSS pseudo-class names with numbers

When newbies develop div+css, they need to name t...

VUE+Canvas implements the game of God of Wealth receiving ingots

Welcome to the previous canvas game series: 《VUE ...

Five ways to implement inheritance in js

Borrowing Constructors The basic idea of ​​this t...