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

后端 未结 7 1784
灰色年华
灰色年华 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:12

    It is true that tomcat does not provide any way to enforce deployment order.

    *Tomcat deploys webapps in following order:*

    1.Any Context Descriptors will be deployed first.

    2.Exploded web applications not referenced by any Context Descriptor will then be deployed. If they have an associated .WAR file in the appBase and it is newer than the exploded web application, the exploded directory will be removed and the webapp will be redeployed from the .WAR

    3.WAR files will be deployed

    > Here is a proposed solution:


    If you want to specify the deployment order then define a context for your web app in $CATALINA_BASE/conf/[enginename]/[hostname]/MyApp.xml

    Tomcat scans $CATALINA_BASE/conf/[enginename]/[hostname]/ by performing File listFiles() which returns a File array sorted by hash value (OS dependent).

    You may use the following code to check in which order webapps will be deployed

    File file = new File("/opt/tomcat/conf/Catalina/localhost");
            File[] files = file.listFiles();
            for (File f : files)
            {
                System.out.println("Filename: " + f.getName());
            }
    

提交回复
热议问题