0

Does the tomcat7-maven-plugin depoy all war-files simultaneously?

Is there a way to configure the plugin to delay the deployment of a war to occur after another war has started?

I have configured the tomcat7-maven-plugin to deploy several war-files. ArtifactB has a runtime dependency to artifactA which is resolved when it is starts up. It seems that the tomcat7-maven-plugin deploys all wars simultaneously, causing artifactB to hang and and it will not recover even after artifactA is up and runnig.

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <path>/</path>
        <port>8080</port>
        <addWarDependenciesInClassloader>true</addWarDependenciesInClassloader>
        <warSourceDirectory>${project.build.directory}/${project.build.finalName}/</warSourceDirectory>
        <webapps>
            <webapp>
                <groupId>the.groupId</groupId>
                <artifactId>artifactA</artifactId>
                <version>1.0-SNAPSHOT</version>
                <type>war</type>
                <asWebapp>true</asWebapp>
            </webapp>
            <webapp>
                <groupId>the.groupId</groupId>
                <artifactId>artifactB</artifactId>
                <version>1.0-SNAPSHOT</version>
                <type>war</type>
                <asWebapp>true</asWebapp>
            </webapp>
        </webapps>
    </configuration>
</plugin>
perseger
  • 77
  • 2
  • 11
  • There is an issue in your design. How are things going to work on the production Tomcat? It would load the WAR files without any particular order. It sounds like you need to extract whatever dependency `artifactB` has on `artifactA` in a separate JAR file, that both `artifactA` and `artifactB` will depend on. – Tunaki Oct 12 '16 at 10:17
  • In production the wars are running in separate Tomcats. It's not a compile-time dependency. The dependency is that artifactB tries to connect to artifactA during start-up (http jax-rs). – perseger Oct 12 '16 at 10:26
  • Alright. I still think there is a design issue here, the dependency needs to be extracted into a separate JAR. – Tunaki Oct 12 '16 at 10:28
  • Even if it might be a design flaw (runtime dependency during startup) I can deploy & run successfully using Intellij Tomcat plugin. Deploying & run using maven (tomcat7:deploy) to a standalone Tomcat works perfectly. But since I'm trying to get it work also for Eclipse-developers I'm moving to use tomcat7:run (which halts). Breaking out the dependency won't work in this case. – perseger Oct 12 '16 at 10:43
  • 1
    Thanks for the comment @Tunaki ! Removing the runtime dependency during start up time solved my problem. I have no need for delayed deployment anymore. – perseger Oct 12 '16 at 12:53

0 Answers0