tomcat-context.xml配置问题

我们先来看看这个 antiResourceLocking 到底是干什么的!
If true, Tomcat will prevent any file locking. This will significantly impact
startup time of applications, but allows full webapp hot deploy and undeploy on
platforms or configurations where file locking can occur. If not specified, the
default value is false.
Please note that setting this to true has some side effects, including the
disabling of JSP reloading in a running server: see Bugzilla 37668.
Please note that setting this flag to true in applications that are outside the
appBase for the Host (the webapps directory by default) will cause the
application to be deleted on Tomcat shutdown. You probably don‘t want to do
this, so think twice before setting antiResourceLocking=true on a webapp that‘s
outside the appBase for its Host.

如果这个参数为true,那么将组织任何文件锁。这将明显的影响应用的启动时间,但允许webapps,可能发生锁的平台和配置下,支持完整的热部署和热卸载。如果不配置,默认值是false;
如果设置为true,有一些副作用,包括屏蔽了JSP文件在运行服务器上的重新加载。
如果设置为true,且部署在HostAppBase目录外面(默认是webapps),在Tomcat关闭的时候将导致应用被删除。
最主要的就翻译到这里了。实际上,如果为false,因为存在锁,在你重新发布的时候,可能出现部分代码无法更新。因为原始文件可能因为被锁住了,不能删除。
当然,如果为false,那么部署的目录就是和包名相同了。如果是false,则会每次都放到一个临时目录下面,一个temp目录。这也是这个配置引发的一个副作用。
另外的一个类似的配置 antiJARLocking 是防止jar类库被锁定而无法删除这个作用的。

 

 

 

  在最近开发过程中出现过这样的情况,当我在myeclipse发布项目的时候,在tomcattemp文件夹中会出现项目的副本,这样的话会产生一些问题如: 
   
当我们在网站中上传东西的时候,由于我们的文件是放在upload文件夹中,当我们再次发布网站项目的时候,tomcat中会产生一个新的项目副本,所以我们之前上传的文件,就不能读取了,例如,我们上传了图片,然后deloy以后,图片就不能显示了。 
   
解决办法: 
    1
、首先确保你的tomcat文件夹下的conf\Catalina\localhost路径中的两个文件host-manager.xml manager.xml 存在 antiResourceLocking antiJARLocking 的值为false ,至于这两个值的含义,可以google下,这里不解析 
    2
、如果这样还不行的话,可以回到项目下的路径WebRoot\META-INF ,看是否有context.xml 这个文件,如果没有可以自己创建,添加以下语句,如果有的话,请把里面的值设为false 
<Context reloadable="true" antiResourceLocking="false"
antiJARLocking="false"/>

时间: 2024-09-06 12:30:59

tomcat-context.xml配置问题的相关文章

Tomcat配置文件context.xml中&lt;Loader delegate="true" /&gt;作用

首先,你需要了解一下JVM的Classloader机制(详细请自行google之).简而言之,JVM的classloader加载继承关系分为BootstarpClassLoader --> ExtClassLoader --> SystemClassLoader,应用的WebAppClassLoader继承自SystemClassLoader,在加载具体某个类时,一般会先委托给父类ClassLoader,当父类ClassLoader无法加载成功时,才会再由子类ClassLoader尝试加载,这

Tomcat 的context.xml

1. 在tomcat 5.5之前: --------------------------------------------------------------- Context体如今/conf/server.xml中的Host里的<Context>元素,它由Context接口定义.每一个<Context元素代表了执行在虚拟主机上的单个Web应用 xml <Context path="/kaka" docBase="kaka" debug=&

在tomcat下context.xml中配置各种数据库连接池(JNDI)

1.   首先,需要为数据源配置一个JNDI资源.我们的数据源JNDI资源应该定义在context元素中.在tomcat6版本中,context元素已经从server.xml文件中独立出来了,放在一个context.xml文件中.因为server.xml是不可动态重加载的资源,服务器一旦启动了以后,要修改这个文件,就得重启服务器才能重新加载.而context.xml文件则不然,tomcat服务器会定时去扫描这个文件.一旦发现文件被修改(时间戳改变了),就会自动重新加载这个文件,而不需要重启服务器

Tomcat 的context.xml说明、Context标签讲解

Tomcat的context.xml说明.Context标签讲解 1. 在tomcat 5.5之前 --------------------------- Context体现在/conf/server.xml中的Host里的<Context>元素,它由Context接口定义.每个<Context元素代表了运行在虚拟主机上的单个Web应用 Xml代码 <Context path="/kaka" docBase="kaka" debug=&quo

Tomcat server.xml配置示例

链接:http://www.importnew.com/17124.html 几乎所有容器类型的应用都会包含一个名为 server.xml 的文件结构.基本上,其中的每个元数据或者配置都是容器完成初始化所需要的.正是由于这些内容都是可配置的,使得软件设计者或架构师可以在容器运行时或销毁时(停止)的情况下注入需要的服务.明白这一点,其重要性不亚于明白代码或软件的工作机制. 对于这篇文章,我们将通过分析 server.xml 文件来理解和配置 appache tomcat 服务器. 准备工作: 安装

Tomcat Context

1.打开C:/Tomcat/conf/server.xml,在<host></host>之间加入代码: <Context path="" docBase="E:/tomcatApp/JeasyCMS" debug="0" reloadable="true" crossContext="true"/> 这样重新启动tomcat,我们的主目录就被设置为jeasyCMS这个项目

Tomcat web.xml配置参数详解

Apache Tomcat Configuration Reference - The Context Containerhttps://tomcat.apache.org/tomcat-5.5-doc/config/context.html tomcat web.xml 配置详解 - titan_max的专栏 - CSDN博客https://blog.csdn.net/titan_max/article/details/52462447 java - Deploy tomcat webapp

tomcat web.xml启动加载类

tomcat web.xml启动加载类 2010-03-30 22:31suitieming | 分类:JAVA相关 | 浏览3870次 我写了一个程序配在tomcat上 想启动tomcat的时候自动运行这个类 怎么配置XML文件类名Test 分享到: 2010-03-31 01:57提问者采纳 答题闯关,过关即送礼!快来参加~ 把你需要启动时自动运行的类做成一个Servlet,然后在web.xml做如下配置:  <servlet>   <servlet-name>StartupL

spring context.xmL配置数据库事务以及aop

!-- from the file context.xml --> <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xmlns:aop