title: Maven Cargo does not stop the container
body: <p>I have a maven project where I want to use the Cargo-Maven-Plugin (1.1.1) to start and stop a tomcat server to run integration tests.</p>
  
  <pre><code>&lt;plugin&gt;
  &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt;
  &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt;
  &lt;version&gt;1.1.1&lt;/version&gt;
  &lt;executions&gt;
      &lt;execution&gt;
          &lt;id&gt;start-container&lt;/id&gt;
          &lt;phase&gt;pre-integration-test&lt;/phase&gt;
          &lt;goals&gt;
              &lt;goal&gt;start&lt;/goal&gt;
          &lt;/goals&gt;
      &lt;/execution&gt;
      &lt;execution&gt;
          &lt;id&gt;stop-container&lt;/id&gt;
          &lt;phase&gt;post-integration-test&lt;/phase&gt;
          &lt;goals&gt;
              &lt;goal&gt;stop&lt;/goal&gt;
          &lt;/goals&gt;
      &lt;/execution&gt;
  &lt;/executions&gt;
  &lt;configuration&gt;                 
      &lt;container&gt;                 
      &lt;type&gt;installed&lt;/type&gt;
      &lt;containerId&gt;tomcat6x&lt;/containerId&gt;
      &lt;zipUrlInstaller&gt;
          &lt;url&gt;http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.zip&lt;/url&gt;
      &lt;/zipUrlInstaller&gt;
  &lt;/container&gt;    
  &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>Starting of the server works fine, but <strong>stopping always failed.</strong></p>
  
  <pre><code>[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.1.1:stop (stop-container) on project test: Execution stop-container of goal org.codehaus.cargo:cargo-maven2-plugin:1.1.1:stop failed: Failed to stop the Tomcat 6.x container. Server port 8080 did not shutdown within the timeout period [120000] -&gt; [Help 1]
  org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.1.1:stop (stop-container) on project test: Execution stop-container of goal org.codehaus.cargo:cargo-maven2-plugin:1.1.1:stop failed: Failed to stop the Tomcat 6.x container.
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
          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:534)
          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: org.apache.maven.plugin.PluginExecutionException: Execution stop-container of goal org.codehaus.cargo:cargo-maven2-plugin:1.1.1:stop failed: Failed to stop the Tomcat 6.x container.
          at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:116)
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
          ... 19 more
  Caused by: org.codehaus.cargo.container.ContainerException: Failed to stop the Tomcat 6.x container.
          at org.codehaus.cargo.container.spi.AbstractLocalContainer.stop(AbstractLocalContainer.java:220)
          at org.codehaus.cargo.maven2.ContainerStopMojo.doExecute(ContainerStopMojo.java:49)
          at org.codehaus.cargo.maven2.AbstractCargoMojo.execute(AbstractCargoMojo.java:278)
          at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
          ... 20 more
  Caused by: org.codehaus.cargo.container.ContainerException: Server port 8080 did not shutdown within the timeout period [120000]
          at org.codehaus.cargo.container.spi.AbstractLocalContainer.waitForPortShutdown(AbstractLocalContainer.java:363)
          at org.codehaus.cargo.container.spi.AbstractLocalContainer.waitForPortShutdown(AbstractLocalContainer.java:297)
          at org.codehaus.cargo.container.tomcat.internal.AbstractCatalinaInstalledLocalContainer.waitForCompletion(AbstractCatalinaInstalledLocalContainer.java:190)
          at org.codehaus.cargo.container.spi.AbstractLocalContainer.stop(AbstractLocalContainer.java:214)
          ... 23 more
  </code></pre>
  
  <p>I have tested it with several projects, add at least with an empty project (noting except an web.xml) but always the same result. I tested is with tomcat6, tomcat7 and even with embedded Jetty6 and 7, but always the same exception. I have added a delay of 5 seconds between start and stop (via a integration test), but this does not help.</p>
  
  <p>When I have a look at the log files, and the running processes, it seem that the tomcat is stopped, but cargo did not notice it.</p>
  
  <pre><code>24.06.2011 17:38:07 org.apache.catalina.startup.Catalina start
  INFO: Server startup in 694 ms
  24.06.2011 17:38:07 org.apache.coyote.http11.Http11Protocol pause
  INFO: Pausing Coyote HTTP/1.1 on http-8080
  24.06.2011 17:38:08 org.apache.catalina.core.StandardService stop
  INFO: Stopping service Catalina
  24.06.2011 17:38:08 org.apache.coyote.http11.Http11Protocol destroy
  INFO: Stopping Coyote HTTP/1.1 on http-8080
  </code></pre>
  
  <p>So my question is:</p>
  
  <ul>
  <li>Do I something wrong?</li>
  <li>Is it a bug?</li>
  <li>Is there any workarround?</li>
  </ul>