Tomcat的资源锁定

更新了某个webapp,把新的WAR包放到webapps目录下,Tomcat就会自动把原来的同名webapp删除,并把WAR包解压,运行新的webapp。但是,有时候Tomcat并不能把旧的webapp完全删除,通常会留下WEB-INF/lib下的某个jar包,必须关闭Tomcat才能删除,这就导致自动部署失败。
解决方法是在<Context>元素中增加一个属性antiResourceLocking=”true”,默认是”false”。但是这样会带来一个问题,Tomcat在运行对应的webapp时,会把下面的文件复制到一个临时目录里,所以如果你在服务器运行的时候修改了某个JSP,Tomcat并不会发现,看到的还是修改前的那个页面。

以下内容来自Tomcat文档:Context标签的位置Context elements may be explicitly defined:

  • in the $CATALINA_HOME/conf/context.xml file: the Context element information will be loaded by all webapps
  • in the $CATALINA_HOME/conf/[enginename]/[hostname]/context.xml.default file: the Context element information will be loaded by all webapps of that host
  • in individual files (with a “.xml” extension) in the $CATALINA_HOME/conf/[enginename]/[hostname]/ directory. The name of the file (less the .xml) extension will be used as the context path. Multi-level context paths may be defined using #, e.g. context#path.xml. The default web application may be defined by using a file called ROOT.xml.
  • if the previous file was not found for this application, in an individual file at /META-INF/context.xml inside the application files
  • inside a Host element in the main conf/server.xml

相关帖子:
  • No Related Posts
  • micas Jun 27th 2007 11:40 am tomcat No Comments yet Trackback URI Comments RSS

    Leave a Reply

    You must be logged in to post a comment.