Jado
Jado

Reputation: 1

Tomcat restarts with errors (exit 143), runs and then fails after time

This is my first time asking a question on Stack Overflow. I recently configured an Ubuntu 16.04 virtual private server to host a web application. I run ngnix on a Tomcat server that reads and writes to a MySQL database. The application runs fine except for the fact that Tomcat restarts itself once in a while which results in a 500 error that stems from a "broken-pipe" when anyone tries to login (i.e. make a connection to the database). I will post an image of the 500 next time it happens. I went into my vps and looked at my Tomcat restart message. This is what I see: Tomcat status message.

I also did a little diving into the Tomcat logs and this is a log file that corresponds with that restart time: Tomcat log file

I did some research to try and solve this myself, but with no success. I believe that the exit=143 is the process being terminated by another program or the system itself. I also have done some moving of the mysql-connector-java.jar. I read that it should be located in the Tomcat/lib directory and not in the WEB-INF of the web application. Perhaps I need to configure other settings.

Any help or any direction would be much appreciated. I've fought this issue for a week with having learned much, but accomplished little.

Thanks

Upvotes: 0

Views: 3687

Answers (2)

Roland Krüger
Roland Krüger

Reputation: 904

While I don't think I am able to see to the core of the problem you have with your overall setup given the small excerpt of your log files, one thing strikes the eye. In the Tomcat log, there is the line

A valid shutdown command was received via the shutdown port. Stopping the server instance.

This explains why the server was restarted. Someone (some external process, a malicious attacker, script, or whatever. Could be anything depending on the setup of your server) sent a shutdown command to Tomcat's shutdown port (8005 by default) which made the Tomcat shut down.

Refer to OWASP's recommendations for securing a Tomcat server instance for fixing this possible security whole.

Regarding the ostensible Hibernate problems you have, I don't get enough information from your logs to make a useful statement. But you can leave the MySQL jar in Tomcat/lib, since this is not the root cause of your problem.

Upvotes: 0

Andreas
Andreas

Reputation: 159096

Look at the timeline. It starts at 19:49:23.766 in the Tomcat log with this message:

A valid shutdown command was received via the shutdown port. Stopping the Server instance.

Exit code 143 is a result of that shutdown and doesn't indicate anything.

The question you need answered is: Who send that shutdown command, and why?


On a side note: The earlier messages indicates that Tomcat lost connection to the database, and that you didn't configure a validation query. You should always configure that, since database connections in the connection pool will go stale, and that needs to be detected.


Theory: Do you have some monitoring service running that tests your application being up? Does that monitoring detect a timed-out database connection, classify that as a hung webapp and auto-restart Tomcat?

Upvotes: 1

Related Questions