Reputation: 9526
I have an application running in a tomcat container in Windows environment. When I have to update the application, the tomcat windows service is stopped, new ROOT.war file is copied in the webapps folder and tomcat service is restarted.
Sometimes it happens that the ROOT.war extraction fails and the extracted ROOT folder has only few subfolder and few files. Obviously the following application startup fails. To solve this problem I have to stop tomcat, delete ROOT folder and run in again to let tomcat re-extract the ROOT.war again from the beginning.
I cannot understand why sometimes it happens and sometimes no. However, it makes impossibile to me to create an automatic update. It is too risky.
Do you have any idea why it can happen?
Upvotes: 0
Views: 1845
Reputation: 16185
Remark: if you are updating the application while Tomcat is running you need to either:
tryAddServiced
(before Tomcat 9.0 addServiced/isServiced
) before any modification to the webapps
directory and removeServiced
afterwards. This can be done through JMX on the bean Catalina:type=Deployer,host=<your_host_name>
,which prevents Tomcat from immediately deploying the application until the copy operation is finished.
To prevent the OS from locking the files in the webapps/ROOT
folder you have two options:
antiResourceLocking="true"
as already suggested by Svetlin, which basically forces Tomcat to copy webapps/ROOT
to a uniquely named temporary directory before deployment (the copy will be locked, webapps/ROOT
will not),ROOT##001.war
, ROOT##002.war
, etc. This is basically an explicit version of the antiResourceLocking
feature with the additional advantage of letting clients transition fluently between the old and new app version.Upvotes: 0
Reputation: 141
Resources are not released. So, when you try to update the existing war file, tomcat is not able to delete the older files before deployment/redeployment.
To resolve this issue, ensure that:
If you want a more reliable way to do this, you may use jrebel or a free version of the same. There are other ways to update code. Basically, standalone tomcat is not worth anything more than a development server.
Upvotes: 1