简体   繁体   English

取消部署 Tomcat Web 应用程序时如何防止文件锁定?

[英]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.我在 tomcat 7 中使用管理器应用程序,但我无法完全取消部署应用程序。

It says FAIL - Unable to delete [F:\\apache-tomcat-7.0.33\\webapps\\balaji]. The continued presence of this file may cause problems.它说FAIL - Unable to delete [F:\\apache-tomcat-7.0.33\\webapps\\balaji]. The continued presence of this file may cause problems. 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 ??谁能告诉我 tomcat 7 中的内存泄漏是什么,我们该如何解决? I am using windows 7 OS.我正在使用 Windows 7 操作系统。 If i am able to fix it will my un-deploy and re-deploy process run smooth ?如果我能够修复它,我的取消部署和重新部署过程会顺利进行吗?

This is very common in Windows environment but there is a solution via the antiResourceLocking context property:这在 Windows 环境中很常见,但有一个通过antiResourceLocking上下文属性的解决方案:

Open context.xml from /tomcat/conf folder and modify the context to match this :从 /tomcat/conf 文件夹打开 context.xml 并修改上下文以匹配以下内容:

<Context antiResourceLocking="true">

Edit: Updated properties following @JanM comment.编辑:在@JanM 评论之后更新了属性。 Previously it also contained 'antiJARLocking'以前它还包含“antiJARLocking”

This is one of the common issues with tomcat.这是tomcat的常见问题之一。 Tomcat server catches hold of the resources on startup and deploys it. Tomcat 服务器在启动时获取资源并进行部署。 While undeploying, some resource would still be in use by tomcat.在取消部署时,某些资源仍会被 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.它不会释放资源,但与此同时,tomcat 中的另一个线程会尝试清理相同的资源。 Hence, the deletion of those resources would fail.因此,删除这些资源将失败。 One best way is to clean up the application's root directory in webapps manually.一种最好的方法是手动清理 webapps 中应用程序的根目录。

I have come across the same problem in Apache Tomcat/8.0.5.我在 Apache Tomcat/8.0.5 中遇到了同样的问题。 I did the following steps using manager App and it worked for me.我使用 manager App 执行了以下步骤,它对我有用。

  • 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.我认为当我们直接点击取消部署时,首先它会锁定 jars,停止应用程序并尝试取消部署但失败并显示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.如果您真的对状态感到困惑,请关闭浏览器,重新启动 tomcat,打开“管理器应用程序”,单击停止然后取消部署。

Run your IDE as administrator.以管理员身份运行 IDE。 It works for me这个对我有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM