Various problems and solutions in the process of deploying Tomcat to release projects on Linux

Various problems and solutions in the process of deploying Tomcat to release projects on Linux

Deploy the project to the project site test environment

JDK1.8
Tomcat8.5
Maven packaged war
Linux-----Centos
I don't know who gave me the Tomcat on site, uploaded it to the ****** directory of the Linux platform, and decompressed it. Direct Start

Figure 1:

Tomcat directory structure

Question 1

Since this is the first time Tocmat is started, there is no log file. So start ./startup.sh directly. You can then use the following command to dynamically view the log information. Tips after execution No execute permission

./startup.sh & tailf ../logs/catalina.out

Problem Analysis: The current user does not have permission to run the .sh executable file

Problem solving: Use command: chmod u+x *.sh. Execute in the tomcat/bin directory

Command analysis: It means adding executable permissions to the owners of all .sh files in the current directory.

  • chmod is the abbreviation of the permission management command change the permissions mode of a file
  • u stands for owner;
  • x represents execution permission;
  • “+” indicates adding permissions.
  • You can also specify a file separately, such as: chmod u+x abc.sh
  • Then start it with ./startup.sh.

Figure 2:

Insufficient permissions displayed.

Question 2

After startup, an error message appears saying that the file in the ***** directory cannot be found.

Problem Analysis: This problem occurs because multiple Context environments are configured in the server.xml file of Tomcat. However, no project is deployed in the specified directory.

Problem solution: Delete all Context in the server.xml file. Delete all deployed projects under the tomcat directory webapps and wtpwebapps. At this time, just start a separate ebank. Startup successful, access to 8080 successful.

Figure 3:

server.xml directory with Context.

Question 3

Add the war packaged by Maven to the tomcat server webapps. Then start it. But the error port is occupied.

Problem Analysis: This operation is performed without pausing the previous step. This causes the port to be occupied. But after pausing Tomcat directly, it still reports that the port is occupied

Problem solving: Use a more violent approach:
Query the ebank process ID: ps aux|grep tomcat
Kill the process directly: kill-9 PID Kill the tomcat process, and then it can be started normally Figure 4:

Port occupied error message

Question 4

Although it can be started normally at this time, an error is reported: java.lang.OutOfMemoryError: PermGen space (prompting memory overflow, which belongs to the memory overflow of the permanent area).

Problem analysis: Tomcat's memory parameters have not been set before. The currently deployed project occupies a large amount of memory and loads many classes. This results in insufficient memory in the permanent area.

Solution: Copy the catalina.sh file under tomcat's bin directory and modify it, and back up the original one. Find the cygwin=false position in the catalina.sh file and add the parameter in front of it. Note that the quotation marks should be included.
JAVA_OPTS="-Xms256m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m"
Replace the modified file in tomcat/bin.

Figure 5:

Heap memory overflow error message

Figure 6:

Modified content of catalina.sh file

Question 5

At this time, it is restarted, but it prompts that the catalina.sh file cannot be found?

Problem analysis: Because the catalina.sh execution file is called in the startup.sh execution file. Thereby starting the Tomcat service. Then use the command ll to view the bin directory. The problem was found that the catalina.sh file was no longer an executable file. (Not green) Problem solution: Use chmod u+x catalina.sh again to give it executable permissions.

Figure 7:

In the startup.sh file, call the catalina.sh execution file

Figure 8: The figure takes hello.sh as an example. (displayed in black, different from catalina.sh)

Distinguish whether it is an executable file

Question 6

The startup was successful, but the project could not be accessed in the browser, but access to 8080 was successful.

Problem analysis: It is found in the webapps directory of Tomcat that each War package has a version number after being decompressed by Tocmat (the war package is generated by Maven packaging and has a version number). Solution to the problem that the correct address accessed by the browser is without the version number: delete the project and rename the War package. Start again. So far all is successful Figure 8:

war project with version number in the webapps directory

Additional commands

Clear the log:

echo -n "" > ../logs/catalina.out
	Fixed syntax: echo -n "" >

Check the log size:

du -h ../logs/catalina.out
	Fixed syntax: du -h >

This is the end of this article about solving various problems in the process of deploying Tomcat on Linux and releasing projects. For more relevant content about deploying Tomcat on Linux, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Linux (center OS7) installs JDK, tomcat, mysql to build a java web project running environment
  • Detailed graphic tutorial on installing and uninstalling Tomcat8 on Linux
  • Steps to monitor Tomcat status and start it automatically using shell scripts under Linux
  • Install tomcat and deploy the website under Linux (recommended)
  • Linux (CentOS7) installs Tomcat and sets Tomcat as a startup item (taking tomcat8 as an example)
  • Install three or more tomcats under Linux system (detailed steps)
  • How to start and stop Tomcat service by writing shell script in Linux environment
  • How to change the tomcat port number in Linux

<<:  JS implements simple addition and subtraction of shopping cart effects

>>:  js implements form validation function

Recommend

Deep understanding of line-height and vertical-align

Several concepts Line box: A box that wraps an in...

Docker installs redis 5.0.7 and mounts external configuration and data issues

Redis is an open source NoSQL database written in...

IIS configuration of win server 2019 server and simple publishing of website

1. First remotely connect to the server 2. Open S...

The main idea of ​​​​dynamically setting routing permissions in Vue

I have seen some dynamic routing settings on the ...

How to use VirtualBox to build a local virtual machine environment on Mac

1. Big Data and Hadoop To study and learn about b...

Detailed explanation of CSS text decoration text-decoration &amp; text-emphasis

In CSS, text is one of the most common things we ...

Explanation of the usage scenarios of sql and various nosql databases

SQL is the main trunk. Why do I understand it thi...

Detailed explanation of the difference between JavaScript onclick and click

Table of contents Why is addEventListener needed?...

Summary of JavaScript JSON.stringify() usage

Table of contents 1. Usage 1. Basic usage 2. The ...

Docker case analysis: Building a MySQL database service

Table of contents 1 Create configuration and data...

Tutorial on installing phpMyAdmin under Linux centos7

yum install httpd php mariadb-server –y Record so...

Guide to Efficient Use of MySQL Indexes

Preface I believe most people have used MySQL and...