放置新的 war 文件时,Tomcat webapp 文件夹被破坏

标签 tomcat deployment

通常,当我将更新的 WAR 文件放入 Tomcat 的 webapps 文件夹时,相应的 webapp 会自动更新。

但有时,当我放入一个更新的 WAR 文件时,会发生一件奇怪的事情:除了一些随机的文件集合之外,大部分 webapp 的文件夹都被删除了。当然,在这种情况下,webapp 不再有效。为了让它工作,我必须停止 Tomcat,完全删除该 webapp 的文件夹,然后重新启动 Tomcat。

在将 WAR 文件放入 webapps 之前,我试图从 Tomcat 管理器中停止 webapp - 它没有帮助。

我尝试将 autodeploy 和/或 unpackwars 更改为 false,但是当我放入新的 warfile 时,webapp 根本没有更新。

我也尝试过使用Jenkins的部署插件,但是出现了同样的问题。

系统规范:Windows 2003 上的 Tomcat 7。

最佳答案

根据 Tomcat 7 配置指南:http://tomcat.apache.org/tomcat-7.0-doc/config/host.html#Automatic%20Application%20Deployment

"Updating a WAR file will trigger an undeploy of the application, with the removal of any associated expanded directory, context file and work directory. Any current user sessions will not be persisted... The application will be redeployed the next time the auto deployer checks for changes."

问题可能是自动部署器还没有完成删除扩展目录,而另一个线程开始重新部署它。

我的解决方法是删除旧的 war-file,等到目录被删除,然后才放入新的 war-file,因为:

"Deleting a WAR file will trigger an undeploy of the application, with the removal of any associated expanded directory, context file and work directory. Any current user sessions will not be persisted."

关于放置新的 war 文件时,Tomcat webapp 文件夹被破坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9896102/

相关文章:

tomcat - 在运行时定义 log4j 文件位置

java - apache tomcat 上的 jsp servlet 中的 session 不匹配

tomcat - 如何使用在 Mac 上运行的 Jenkins 重启远程 Tomcat

java - Tomcat 无法实例化 org.apache.log4j.varia.LevelMatchFilter 类

java - 在 tomcat webapp 中设置身份验证的最佳方法是什么?

java - 减少TomcatDeployer的间隔

node.js - Next.js 应用程序在服务器上抛出错误,但在本地不抛出错误

tomcat - 使用 Gradle Cargo 插件部署到多个环境

ruby - 如何确定puppet类的运行顺序?

java - Tomcat5 "Null component"和 "HTTP Status 404 - Servlet jsp is not available"