Tomcat 8 上的 AntiResourceLocking [英] AntiResourceLocking on Tomcat 8

查看:20
本文介绍了Tomcat 8 上的 AntiResourceLocking的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在 Windows 上运行 Tomcat8,由于 Windows 锁定了属性的 jar,重新部署应用程序有时会失败.

We're running Tomcat8 on Windows and redeploying applications sometimes fails due to Windows locking jars of properties.

我发现这个文档说你必须将 AntiResourceLocking 属性添加到 Context 元素:Apache Tomcat 8 配置参考

I found this documentation saying that you have to add the AntiResourceLocking-attribute to a Context-element: Apache Tomcat 8 Configuration Reference

我们所有的服务器都是使用脚本构建的,因此在 server.xml 中执行此操作应该没有问题(如果有效?):

All our servers are built using scripts so doing this in the server.xml should not be a problem (if it works?):

<Engine name="Catalina" defaultHost="localhost">
  <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
    <Context antiResourceLocking="true"></Context>
  </Host>
</Engine>

当服务器重新启动 Tomcat 时,会打印以下错误,我们不知道什么是错误的:

When the server restarts Tomcat prints the following errors and we have no real clue as to what is wrong:

Failed to initialize component     [StandardEngine[Catalina].StandardHost[localhost].StandardContext[null]]

Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[null]]

Caused by: java.lang.NullPointerException
at org.apache.catalina.core.StandardContext.getObjectKeyPropertiesNameOnly(StandardContext.java:6233)

以前有人做过吗?我错过了什么吗?

Has anyone done this before? Am I missing something?

推荐答案

你缺少的是 conf/server.xmlconf/context.xml 的区别.

What you are missing is the difference between conf/server.xml and conf/context.xml.

当您将 <Context .../> 元素添加到 conf/server.xml 时,您就是在定义一个单独的上下文(Web 应用程序).这相当于在 CATALINA_BASE/conf/// 中定义一个 元素;.xml 或打包为 Web 应用程序一部分的 /META-INF/context.xml 文件.

When you add a <Context .../> element to conf/server.xml you are defining an individual context (web application). This is equivalent to defining a <Context .../> element in CATALINA_BASE/conf/<engine-name>/<host-name>/<context-name>.xml or in a /META-INF/context.xml file packaged as part of the web application.

conf/context.xml 中的 元素定义了所有上下文(Web 应用程序)的默认值.

The <Context .../> element in conf/context.xml defines defaults for all contexts (web applications).

您在 conf/server.xml 中添加的单个 Context 元素失败,因为您没有指定路径.

The single Context element you have adding in conf/server.xml is failing because you haven't specified a path.

如果你真的想为所有 web 应用程序启用反资源锁定,那么你需要添加 antiResourceLocking="true" 作为一个属性到 <Context .../> 元素CATALINA_BASE/conf/context.xml.

If you really want to enable anti-resource locking for all web applications then you need to add antiResourceLocking="true" as an attribute to the <Context .../> element in CATALINA_BASE/conf/context.xml.

顺便说一句,此选项只是解决 Web 应用程序中资源泄漏的方法.您可能需要考虑花时间修复这些资源泄漏.

As an aside, this option is only a work-around for resource leaks in your web application. You might want to consider taking the time to fix those resource leaks.

这篇关于Tomcat 8 上的 AntiResourceLocking的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆