Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent file locking when undeploying a Tomcat web app?

I am using the manager app in tomcat 7, and i am unable to undeploy an application completely.

It says FAIL - Unable to delete [F:\apache-tomcat-7.0.33\webapps\balaji]. The continued presence of this file may cause problems.

I read somewhere its because of some phenomenon called memory leak , and if we fix it the issue will be solved.

Can anyone tell me what is this memory leak in tomcat 7, and how can we fix it ?? I am using windows 7 OS. If i am able to fix it will my un-deploy and re-deploy process run smooth ?

like image 514
bali208 Avatar asked Feb 14 '13 10:02

bali208


3 Answers

This is very common in Windows environment but there is a solution via the antiResourceLocking context property:

Open context.xml from /tomcat/conf folder and modify the context to match this :

<Context antiResourceLocking="true">

Edit: Updated properties following @JanM comment. Previously it also contained 'antiJARLocking'

like image 134
mvlupan Avatar answered Nov 01 '22 01:11

mvlupan


This is one of the common issues with tomcat. Tomcat server catches hold of the resources on startup and deploys it. While undeploying, some resource would still be in use by tomcat. It would not yet have released the resource, but at the same time, another thread in tomcat would try to cleanup the same resources. Hence, the deletion of those resources would fail. One best way is to clean up the application's root directory in webapps manually.

like image 13
Amith Koujalgi Avatar answered Nov 01 '22 02:11

Amith Koujalgi


I have come across the same problem in Apache Tomcat/8.0.5. I did the following steps using manager App and it worked for me.

  • Close the browser including all tabs (to delete cache).
  • Re-open the 'Manager App' and first make sure that the application is stopped (start button should be enabled).
  • Now click on undeploy.

I think when we directly click on undeploy, first it locks the jars, stops the application and try to undeploy but fails with FAIL - Unable to delete message.

If you really confused with status, close the browser, restart tomcat, open 'manager App', click on stop and then undeploy.

like image 2
Sumant Avatar answered Nov 01 '22 02:11

Sumant