10

Cargo-Maven-Plugin (1.1.1) を使用して tomcat サーバーを起動および停止し、統合テストを実行する Maven プロジェクトがあります。

<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 が停止しているように見えますが、cargo はそれに気づきませんでした。

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

だから私の質問は:

  • 私は何か間違っていますか?
  • バグですか?
  • 回避策はありますか?
4

2 に答える 2

6

私も同じ問題を抱えていました。Hudson サーバーからコンテナーを停止できませんでしたが、同じ pom.xml と同じ Maven の目標とオプションを使用してローカル マシンで正しく停止していました。

問題は、Hudson が Tomcat 上にあり、コンテナーと Tomcat が同じポートを使用していたことです。サーブレットのポートを 8080 から 8181 に、AJP のポートを 8009 から 8012 に変更すると (番号は任意に選択されました)、問題は解決し、「停止」の目標は正常に実行されました。

競合が2つのTomcat間であったため、2つのポートを変更する必要がありました。競合がTomcatと他の何かとの間である場合、2つの変更のうちの1つだけが必要になる可能性があります。

ポートを変更するために使用した2行は次のとおりです。

<configuration>
     ...
     <properties>
        ...
        <cargo.servlet.port>8181</cargo.servlet.port>
        <cargo.tomcat.ajp.port>8012</cargo.tomcat.ajp.port>
        ...
    </properties>
    ...
</configuration>
于 2011-07-12T15:37:31.570 に答える
6

マシンのポート 8080 で別のものがリッスンしている可能性があります。これにより、貨物は tomcat が停止しなかったと認識します。cargo 設定を介して tomcat の AJP ポートをあまり一般的ではないものに変更できます。詳細については、このブログ投稿を参照してください: http://kreskasnotes.blogspot.com/2011/07/problem-with-shutting-down-tomcat-via.html

于 2011-07-04T17:17:37.660 に答える