通常,当我将更新的 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/