简体   繁体   English

Tomcat更新context.xml,但不应更新

[英]Tomcat updates context.xml but should not

Tomcat documentation (http://tomcat.apache.org/tomcat-6.0-doc/config/context.html) Tomcat文档(http://tomcat.apache.org/tomcat-6.0-doc/config/context.html)

Only if a context file does not exist for the application in the $CATALINA_BASE/conf/[enginename]/[hostname]/, in an individual file at /META-INF/context.xml inside the application files. 仅当$ CATALINA_BASE / conf / [enginename] / [hostname] /中的应用程序的上下文文件不存在时,该文件才位于应用程序文件内/META-INF/context.xml的单个文件中。 If the web application is packaged as a WAR then /META-INF/context.xml will be copied to $CATALINA_BASE/conf/[enginename]/[hostname]/ and renamed to match the application's context path. 如果将Web应用程序打包为WAR,则/META-INF/context.xml将被复制到$ CATALINA_BASE / conf / [enginename] / [hostname] /并重命名以匹配应用程序的上下文路径。 Once this file exists, it will not be replaced if a new WAR with a newer /META-INF/context.xml is placed in the host's appBase. 该文件存在后,如果将具有更新的/META-INF/context.xml的新WAR放置在主机的appBase中,则将不会替换该文件。

Text in bold is clear. 粗体字清晰。 But I notify as not true. 但我通知为不正确。 (I need exactly this behaviour) (我确实需要这种行为)

Here are steps: 步骤如下:

  1. aaa.war with context.xml included into META-INF META-INF中包含带有context.xml的aaa.war
  2. copy to webapps. 复制到webapps。 tomcat deploys. Tomcat部署。 File conf\\Catalina\\localhost\\aaa.xml OK 文件conf\\Catalina\\localhost\\aaa.xml确定
  3. change aaa.war by changing META-INF/context.xml 通过更改META-INF / context.xml来更改aaa.war
  4. copy to webapps 复制到webapps
  5. File conf\\Catalina\\localhost\\aaa.xml is changed!!! 文件conf\\Catalina\\localhost\\aaa.xml已更改!!!

What is wrong? 怎么了? Is it a bug or a hidden feature? 是错误还是隐藏功能?

Background - the issue I want to resolve: 背景-我要解决的问题:

Configuration independent build and installation. 独立于配置的构建和安装。 I plant to ship war file. 我厂运送战争档案。 Client per-configures his Tomcat using his own settings. 客户端使用自己的设置对Tomcat进行每个配置。 when I ship a new release I just delivery the war without config and when deployed it will use client specific configuration. 当我发布新版本时,我只是在没有配置的情况下交付战争,而在部署时它将使用客户端特定的配置。

By documentation the best place is the context.xml But if it overwritten each time it make no sense to use at all. 通过文档记录,最好的地方是context.xml,但是如果每次都覆盖它,则根本就没有意义。 (why would I use JNDI and such a things if new deliverable has to created? Changing something in build-time is not a big configuration advantage.) (如果必须创建新的可交付成果,我为什么要使用JNDI之类的东西?在构建时更改某些内容并不是很大的配置优势。)

Environment: windows, tomcat 6.0.33 环境:Windows,tomcat 6.0.33

I've run into the same problem and the documentation is at least inadequate, if not directly misleading. 我遇到了同样的问题,并且即使没有直接误导,文档也至少是不够的。

The problem is, that if you copy a new version of an already deployed WAR file to the webapps directory, Tomcat will not redeploy the existing application but undeploy the old application and then deploy the new application. 问题是,如果将已经部署的WAR文件的新版本复制到webapps目录中,则Tomcat不会重新部署现有应用程序,而是取消部署旧应用程序,然后部署新应用程序。 The difference may first seem insignificant, but the problem is that during undeployment of the old application, any context files in conf/Catalina/localhost are deleted as well. 乍一看,差异似乎微不足道,但是问题是,在取消部署旧应用程序的过程中,conf / Catalina / localhost中的所有上下文文件也会被删除。 Then, the new context file from the current WAR file will be copied to conf/Catalina/localhost during deployment of the new application. 然后,将在部署新应用程序期间将当前WAR文件中的新上下文文件复制到conf / Catalina / localhost。

The only feasible solution I've found is not to deploy the new application as a WAR file, but to replace or overwrite the expanded directory, eg not to copy aaa.war to webapps/ but to unpack aaa.war directly into webapps/aaa/. 我发现的唯一可行的解​​决方案不是将新应用程序部署为WAR文件,而是替换或覆盖扩展目录,例如,不是将aaa.war复制到webapps /,而是将aaa.war直接解压缩到webapps / aaa中/。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM