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

Solution for creating multiple databases when Docker starts PostgreSQL

1 Introduction In the article "Start Postgre...

Detailed explanation of MySQL string concatenation function GROUP_CONCAT

In the previous article, I wrote a cross-table up...

Docker image access to local elasticsearch port operation

Using the image service deployed by docker stack,...

Steps for docker container exit error code

Sometimes some docker containers exit after a per...

Hyperlink icon specifications: improve article readability

1. What is the hyperlink icon specification ?<...

JavaScript to achieve simple drag effect

This article shares the specific code of JavaScri...

MySQL 5.7 deployment and remote access configuration under Linux

Preface: Recently I am going to team up with my p...

Mysql backup multiple database code examples

This article mainly introduces the Mysql backup m...

How to install MySQL 5.7.29 with one click using shell script

This article refers to the work of 51CTO blog aut...

An example of implementing a simple infinite loop scrolling animation in Vue

This article mainly introduces an example of Vue ...

How to choose and use PNG, JPG, and GIF as web image formats

So which one of these formats, GIF, PNG, and JPG,...

Why the explain command may modify MySQL data

If someone asked you whether running EXPLAIN on a...

Modify the jvm encoding problem when Tomcat is running

question: Recently, garbled data appeared when de...

Vue Virtual DOM Quick Start

Table of contents Virtual DOM What is virtual dom...