我有一個maven項目,我想使用Cargo-Maven-Plugin(1.1.1)啓動和停止一個運行集成測試的tomcat服務器。Maven Cargo不會停止容器
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<container>
<type>installed</type>
<containerId>tomcat6x</containerId>
<zipUrlInstaller>
<url>http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.zip</url>
</zipUrlInstaller>
</container>
</configuration>
</plugin>
服務器啓動正常,但停止總是失敗。
[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] -> [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
我有幾個項目進行了測試,至少有一個空的項目(除的web.xml中提),但始終不變的結果添加。我測試過的是tomcat6,tomcat7,甚至嵌入了Jetty6和7,但總是出現相同的異常。我在啓動和停止之間增加了5秒的延遲時間(通過集成測試),但這沒有幫助。
當我看看日誌文件和正在運行的進程時,似乎tomcat停止了,但貨物沒有注意到它。
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
所以我的問題是:
- 我是否出錯了?
- 這是一個錯誤?
- 是否有任何workarround?
遇到這種最近,幾乎完全一樣的設置,完全一樣的問題。我很感興趣地聽到的解決方案 - 我們有,由於其他原因,需要打破跨多個構建分佈式的階段構建 - 讓我們感動的Tomcat啓動/停止行動統一到螞蟻,它沒有工作(所有策劃通過Hudson/Jenkins)。我們做墳的一個小問題,就是構建如何滋生tomcat的JVM,以及如何構建/ CI服務器會殺子進程,如果你在沒有處理的菌種標誌,也許缺少的Maven選項的地方? –
@Al Baker:我在Cargo Bug Tracker上打開了一個Bug(http://jira.codehaus.org/browse/CARGO-1005)。但我們仍未找到問題的原因。因爲它與其他系統一起工作。可能會有幫助,我會添加一條評論來描述您的設置(並且可能會驗證我附加到該錯誤的示例項目是否適用於您)。 – Ralph
它幾乎完全一樣,但沒有url安裝程序 - 我們在一個斷開的網絡 –