7

我正在做一个项目,我们将使用 Tomcat 6.0.20 进行开发和生产。

我遇到了一些与热部署相关的问题,需要在 server.xml 中将 Context.antiResourceLocking 设置为 false。我对 antiResourceLocking 和 antiJARLocking 有一些疑问。我已经浏览了http://tomcat.apache.org/tomcat-6.0-doc/config/context.html上的参考资料。

我无法理解 JAR 被锁定或资源被锁定到底是什么意思。到目前为止,我所读到的是锁定问题通常出现在您取消部署由于文件/jar 锁定的进程而失败的应用程序时。有人可以指出我可以在此问题上阅读更多内容的任何内容吗?

我的问题是:1)如果我将 antiJARLocking 和/或 antiResourceLocking 设置为 false,我会遇到什么问题?有人可以提供一个例子吗?2) 在生产环境中将这些属性设置为 false 是一种不好的做法吗?2) 锁定不会像在 Windows 机器上那样频繁地发生在 Linux 机器上,这是真的吗?

感谢你的帮助。

谢谢你。

戈文德·N。

4

2 回答 2

5

以下是我对这些问题的回答:

1)据我所知,将 antiJARLocking 和/或 antiResourceLocking 设置为 false 只会在 Windows 上引起问题(尽管我隐约记得一个 Tomcat 开发人员声称它也会影响 Linux ——我忽略了这一点,因为我看到的证据为零它,并且没有例子/详细解释证明它)。

2) 当 Tomcat 在 Windows 上运行时,将这些设置为 false 只是不好的做法。

第二个2)!!十多年来,我一直在多个 Linux 发行版和版本上运行 Tomcat。由于未将这些属性之一设置为 true,我从未见过 jar 锁定或资源锁定问题。据我所知,这不会发生,但这可能取决于您使用的文件系统实现,而且我总是使用 EXT2、EXT3 或 EXT4。

如果您对此仍有疑问,请在 Tomcat 用户邮件列表中询问。

干杯!

Jason Brittain 合著者,Tomcat:权威指南 (O'Reilly)

于 2010-09-01T19:51:51.413 回答
4

1) I had built a system around svn to automatically build and deploy a webapp, the deployment was made via the Tomcat ant tasks, and with antiJARLocking and/or antiResourceLocking to false the application was not undeployed properly, because tomcat could not delete some jars and the log4j.properties config file, thus the deploy failed. So I had to set these properties to true, and tomcat did a copy of the webapp in the temp dir. This makes the deployment slower and with nearly each redeploy the temp dir grew in size, so I had to make a procedure to delete older deployments of my app from the temp dir. It is safe to delete deployments from the temp dir at any time, because tomcat will redeploy the app to the temp dir.

2) From the tomcat docs I understood that the problems with jar locking or resource locking occur only on Windows. I wouldn't set these properties to true in a production environment, because there's no need to redeploy so often, and with java it's always a good idea to do a server restart after redeploy in production (an OutOfMemoryError is always lurking in the dark, even if your own code doesn't leak). Another minor issue is that the app being deployed to the temp dir, if you modify a jsp or another file in the webapps dir, it won't be redeployed unless you copy the changes to the temp dir also.

于 2010-09-28T08:39:00.340 回答