[Project] Tomcat deployment and runtime encountered pit (metaphysics?)

Foreword

Some time ago Ali rented a cloud server, the first to explore the practical operation of built environment, deployment project. I was connecting with Ali cloud servers remotely on a local Linux virtual machine, feeling quite easy to use.

This blog [not] describe processes and procedures environment to build and deploy the project, recording what I encountered the pit.

Pit 1:

Problem Description and error:

The war package into the corresponding directory. Start Tomcat, normal access index.jsp, but access to the following test API error appears. Probably it seemed to be unable to scan the war package.

solve:

The war package at the corresponding position (according to their own situation) decompress into a folder name of the folder is the name of the war package, and then delete war package. The principle of this error is unclear.

Pit 2:

Problem Description and error and resolve:

There may be many people like you with my local tests are normal, the code got nothing moving, the project will be deployed to the cloud server has a problem in. It is very likely that the environment is not the same as a result.

Here's an error I've encountered (shot put final). This error code logic involved, others may not have any reference value.

However, by being given to locate, find sessionFactory a null pointer. It explains: establishing a database connection!

 

The reason the database connection failures there are many:

1, MySQL server is already started

 

2, the wrong project configuration file appears. For example: account number, password, driver ( different versions of MySQL to use a different driver package )

Account number and password I will not say. I speak from the driving issue a jar. I was in a local MySQL 5.7, and cloud server upload is MySQL8. We need to rely on the idea modify the database configuration files and gradle. Here is my revised hibernate configuration file, the main change driver and url. Modified driver might burst red, because the local driver may not correspond jar package. Build.gradle taken to modify the driver package mysql dependent, modify it to 8 or more. Then do not forget, rebuild and re-fight the war package. After the fight the best to confirm whether the war is really inside the configuration file has been modified successfully, to prevent war or the previous package.

 

3, MySQL versions prior to 8.0 encryption rule is mysql_native_password, while MySQL after 8, the encryption rule is caching_sha2_password

May occur error: Authentication plugin 'caching_sha2_password' can not be loaded. Or may not, but the database connection fails there may be the reason! ! !

The encoding rule is the user password can view and modify the corresponding information in the types of system data mysql user table.

On a cloud server log into the MySQL database to see if the user's encryption rules:

use mysql;
select user, host, plugin from user;

The default root account and can not be used with a remote connection, so we either permission to open or add an account (own Baidu). I add here a ysq account for remote access, and modify the user password encryption rules for mysql_native_password;

ALTER USER '用户名'@'host' IDENTIFIED WITH mysql_native_password BY '该用户的密码';

I assume that the ysq user's password is: 123456, it can be seen from the table of host species is "%" (any host). So I had to change its encryption rule, sql statement corresponding to: ALTER USER 'ysq' @ '%' IDENTIFIED WITH mysql_native_password BY '123456';

After the changes, remember to refresh permission.

flush privileges;

Then go to the directory on the cloud server project, find the profile database, the accounts and passwords, encryption rules changed to modify the accounts and their passwords. Then remember to restart Tomcat! ! !

 

View Log

If you still can not find where a problem may wish to see the log have no clue.

View mysql log: vim /var/log/mysqld.log (probably not the same, here is my path)

 

View tomcat log: vim /opt/tomcat/apache-tomcat-9.0.31/logs/catalina.out

If you can not find the tomcat log in which, as the name of the log file called catalina.out, we can find the following command:

find / -name catalina.out

Published 24 original articles · won praise 2 · Views 1900

Guess you like

Origin blog.csdn.net/qq_43290318/article/details/104769757
Recommended