How to prevent file locking when undeploying a Tom

2019-01-20 22:32发布

问题:

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 ?

回答1:

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'



回答2:

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.



回答3:

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.