We are running a website on Tomcat 7.x and the other day Tomcat tried to auto deploy the .WAR three times in succession causing the server to crash. Our operations team informs me that there was no action being carried out on the server at the time. I am also told that auto deploy has been configured as on since the servers were implemented in production over 18 months and that they have not tried to do this before. If there were no changes at the time then it seems that there may be a serious bug in the auto deploy functionality to start to deploy for seemingly no reason. Does anyone have any experience of this happening or know of a bug report where Tomcat kicks off this activity for no explicable reason?
The code says Tomcat is comparing last modified times of exploded WAR files with system time of last deployment.
Is it possible the server timestamp changed to a previous time at that point? Summer time adjustment or something like that?
If there are some catalina logs, I think it's possible to correlate them with the code above to check what exactly happened.
As a side note, generally auto deploy is considered a development time convenience, and disabled in production.
The default behavior for Tomcat is that it will periodically scan the TOMCAT_HOME/webapps directory, the TOMCAT_HOME/conf/Catalina/localhost directory and possibly some other locations looking for files which have changed. Presumably since the time of the last scan, since Tomcat doesn't need the overhead of maintaining a per-file date history. So make sure your system clock is set correctly and that the timestamps in your WARs aren't set to some future date.
In the case of a WAR file in TOMCAT_HOME/webapps, IF there is no existing exploded equivalent directory, the Tomcat deployer will explode the WAR. Thereafter, changes to the WAR file itself won't be tracked, only changes to the files in the exploded WAR. At least up until about Tomcat 7. I haven't checked newer versions of Tomcat.
In the cast of changing a Context file, such as are located in TOMCAT_HOME/conf/Catalina/localhost and possibly other directories (if you define multiple hosts), Tomcat will re-deploy the corresponding WAR using the updated Context.
Tomcat's re-deployment mechanism can be problematic, Especially for versions 4 and up of Tomcat running pre-version 8 JVMs, the Permgen space wasn't completely recovered, so apps using a lot of PermGen space (such as Hibernate-JPA webapps) would tend to crash Tomcat after a couple of deploys due to lack of available PermGen space. Java 8 no longer has PermGen, though.
When it comes to destroying a civilization, gas chambers cannot hold a candle to echo chambers.
posted 3 years ago
Thanks Karthik, Tim for a great welcome to the forum. I will check with my production team but I am fairly sure that there were no time changes on the servers themselves and the .WAR file had not be changed for at least a month, and there should have been no changes to exploded director. The catalina logs only recorded a that Tomcat went in to a standard shutdown and attempted to deploy the .WAR file. This happened three times. I will let you know what they come back with.