Is there a way to enforce a deployment order in tomcat6?

后端 未结 7 1785
灰色年华
灰色年华 2020-12-01 16:37

I have 3 wars in my webapp folder. Two of them are built on services of the third one. I\'m in a testing environment, i.e. I don\'t have control over their architectures, so

7条回答
  •  失恋的感觉
    2020-12-01 17:07

    There are three ways to deploy the webapp.war in Tomcat.

    1. Add Context element inside a Host element in the $CATALINA_BASE/conf/server.xml file.

      
          
      
      
    2. Create the $CATALINA_BASE/conf/[engineName]/[hostName]/[webappName].xml file with content:

      
      
    3. Add the webapp.war file directly in the $CATALINA_BASE/webapps/ directory.

    The following deployment sequence will occur on Tomcat startup:

    1→2→3


    Some explanations:

    • $CATALINA_BASE

      Refer the base directory against which most relative paths are resolved. If you have not configured Tomcat for multiple instances by setting a CATALINA_BASE directory, then $CATALINA_BASE will be set to the value of $CATALINA_HOME, the directory into which you have installed Tomcat.

    • docBase

      The pathname to the web application WAR file. You may specify an absolute pathname for this WAR file, or a pathname that is relative to the appBase directory of the owning Host.

    • engineName:

      The name of the engine associated to the context. The default name is Catalina.

    • hostName:

      The name of the host associated to the context. The default name is localhost.


    Assume that:

    • there are 3 webapps: a.war, b.war and c.war.
    • b.war depends on a.war.
    • c.war depends on b.war.
    • Server.Service.Engine.name = "Catalina"
    • Server.Service.Engine.Host.name = "localhost"
    • Server.Service.Engine.Host.appBase = "webapps"

    Try the following steps:

    1. Put all of the war files to the $CATALINA_BASE/webapps/ directory.
    2. create the $CATALINA_BASE/conf/Catalina/localhost/b.xml file with content:

      
      
    3. Add Context element in the $CATALINA_BASE/conf/server.xml file:

      
          
      
      

    Reference:

    • https://tomcat.apache.org/tomcat-9.0-doc/deployer-howto.html
    • http://tomcat.apache.org/tomcat-9.0-doc/config/context.html

提交回复
热议问题