404 after local Tomcat deployment is deployed to the server normally

        The project is deployed in the local Tomcat and can be accessed normally. Put the war package directly into the cloud server tomcat, and the error 404 was reported. After various troubleshooting, a solution was finally found.

One problem description

        The development tool used by the project is IntelliJ IDEA, which is packaged into a war package and tested locally. The page can be opened normally and the test results meet expectations. Upload the project to the webapps directory of the tomcat of Alibaba Cloud server, and then test it. A 404 error was found and the program page could not be located normally.

Two problem analysis

  1. First, see if the port you need is allowed in the security group on the server.

  2. After the port is released, the firewall needs to be updated. I provide two Linux mirroring methods. Other mirrors can be searched online by themselves.
    CentOS: firewall-cmd --reload
    Ubuntu:sudo ufw reload

  3. See what the error log of Tomcat is

Three, the final solution

        Then the error log here is probably:openFile(null,true) call failed.java.io.FileNotFoundException Permission denied

        It basically means that there is no permission to write to the file, because the project has recorded a log file and written to a certain directory.

        Because it is started directly on the panel, we don't have this permission. We start Ttomcat with root permission. Connect to the server as root, then go to the bin directory where your Tomcat is located, and execute the following line of code:

nohup ./startup.sh &

        We hang up the process and start Tomcat like this to ensure that the service is not stopped when the server connection is closed. Attach the command to stop the Tomcat service:./shutdown.sh

        At this point, the service starts normally, the page can be opened normally, and the functions are normal.

Guess you like

Origin blog.csdn.net/weixin_43899542/article/details/106593193