title: tomcat7-maven-plugin: run multiple webapps but port 8080 already in use
body: <p>I'm trying to use <code>tomcat7-maven-plugin</code> to setup an embedded tomcat container, run webapps in <code>pre-integration-test</code> phase, run integration tests, then shutdown tomcat in <code>post-integration-test</code> phase. The project is a multi-module maven project (contains <code>app1</code>, <code>app2</code>, etc). Parent <code>pom.xml</code> looks like following,</p>
  
  <pre><code>&lt;build&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.tomcat.maven&lt;/groupId&gt;
        &lt;artifactId&gt;tomcat7-maven-plugin&lt;/artifactId&gt;
        &lt;version&gt;2.1&lt;/version&gt;
        &lt;configuration&gt;
          &lt;contextFile&gt;path/to/context.xml&lt;/contextFile&gt;
          &lt;tomcatUsers&gt;path/to/tomcat-users.xml&lt;/tomcatUsers&gt;
          &lt;fork&gt;true&lt;/fork&gt;
        &lt;/configuration&gt;
        &lt;executions&gt;
          &lt;execution&gt;
            &lt;id&gt;tomcat-run&lt;/id&gt;
            &lt;goals&gt;
              &lt;goal&gt;run&lt;/goal&gt;
            &lt;/goals&gt;
            &lt;phase&gt;pre-integration-test&lt;/phase&gt;
          &lt;/execution&gt;
          &lt;execution&gt;
            &lt;id&gt;tomcat-shutdown&lt;/id&gt;
            &lt;goals&gt;
              &lt;goal&gt;shutdown&lt;/goal&gt;
            &lt;/goals&gt;
            &lt;phase&gt;post-integration-test&lt;/phase&gt;
          &lt;/execution&gt;
        &lt;/executions&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>Then I just run <code>mvn clean integration-test --projects=app1,app2</code>. <strong>When the second app is starting</strong>, I get <code>java.net.BindException</code>,</p>
  
  <pre><code>SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-bio-8080"]
  java.net.BindException: Address already in use &lt;null&gt;:8080
      at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:406)
      at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:610)
      at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:429)
      at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init(AbstractHttp11JsseProtocol.java:119)
      at org.apache.catalina.connector.Connector.initInternal(Connector.java:981)
      at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
      at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
      at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
      at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:814)
      at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
      at org.apache.catalina.startup.Tomcat.start(Tomcat.java:335)
      at org.apache.tomcat.maven.plugin.tomcat7.run.AbstractRunMojo.startContainer(AbstractRunMojo.java:1091)
      at org.apache.tomcat.maven.plugin.tomcat7.run.AbstractRunMojo.execute(AbstractRunMojo.java:512)
      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
      at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
      at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
      at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
      at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
      at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
      at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
      at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
  Caused by: java.net.BindException: Address already in use
      at java.net.PlainSocketImpl.socketBind(Native Method)
      at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383)
      at java.net.ServerSocket.bind(ServerSocket.java:328)
      at java.net.ServerSocket.&lt;init&gt;(ServerSocket.java:194)
      at java.net.ServerSocket.&lt;init&gt;(ServerSocket.java:150)
      at org.apache.tomcat.util.net.DefaultServerSocketFactory.createSocket(DefaultServerSocketFactory.java:49)
      at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:393)
      ... 34 more
  </code></pre>
  
  <p>So is there a configuration in <code>tomcat7-maven-plugin</code> to run multiple webapps in an embedded tomcat?</p>