tomcat does not pick the context.xml, it is getting coopied to CATALINA_HOME> conf>Catalina>localhost though

好久不见. 提交于 2019-12-24 11:26:48

问题


My context.xml (in META_INF) folder looks like this:

<?xml version="1.0" encoding="UTF-8"?>


<Context path="MY_CONTEXT_NAME" docBase="${catalina.home}/webapps/MY_APP_NAME"
        debug="0" privileged="true">

</Context>

The problem is, context.xml is getting copied to the CATALINA_HOME> conf>Catalina>localhost folder when I deploy my application war via tomcat manager. However, it is somehow still deploying from default context, that is , app_war_name.

Earlier, it was not even getting copied to localhost folder, I removed the default context.xml form tomcat 6.0>conf folder. After that, the file is at least getting copied. However, the deployment is not happening from the explicit context.xml.

My server.xml host entry looks like this :

  <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="false"
            xmlValidation="false" xmlNamespaceAware="false" >
  </Host> 

回答1:


Read the documentation for the path element of the Context element. It states quite clearly

This attribute must only be used when statically defining a Context in server.xml. In all other circumstances, the path will be inferred from the filenames used for either the .xml context file or the docBase.

Even when statically defining a Context in server.xml, this attribute must not be set unless either the docBase is not located under the Host's appBase or both deployOnStartup and autoDeploy are false. If this rule is not followed, double deployment is likely to result.

Then read the documentation for the docBase element.

The value of this field must not be set unless the Context element is defined in server.xml or the docBase is not located under the Host's appBase.




回答2:


if you deploy again with new context or changed context you need to un-deploy first/ or remove context.xml from conf/.../localhost/yourapp.xml



来源:https://stackoverflow.com/questions/19249969/tomcat-does-not-pick-the-context-xml-it-is-getting-coopied-to-catalina-home-co

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!