Maven Cargo 不会停止容器

发布于 2024-11-17 04:20:28 字数 5919 浏览 2 评论 0原文

我有一个 Maven 项目,我想在其中使用 Cargo-Maven-Plugin (1.1.1) 来启动和停止 tomcat 服务器来运行集成测试。

<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

所以我的问题是:

  • 我做错了什么吗?
  • 这是一个错误吗?
  • 有什么解决方法吗?

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.

<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>

Starting of the server works fine, but stopping always failed.

[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

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.

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.

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

So my question is:

  • Do I something wrong?
  • Is it a bug?
  • Is there any workarround?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小嗷兮 2024-11-24 04:20:28

可能有其他东西正在侦听您计算机上的端口 8080。这会让cargo认为tomcat没有停止。您可以通过货物配置将 tomcat 的 AJP 端口更改为不常见的端口。请参阅此博客文章了解更多详细信息:
http://kreskasnotes.blogspot.com/2011 /07/problem-with-shutting-down-tomcat-via.html

It could be that something else is listening on port 8080 on your machine. This would make cargo think that tomcat didn't stop. You can change the AJP port for tomcat via cargo configuration to something less common. See this blog post for more details:
http://kreskasnotes.blogspot.com/2011/07/problem-with-shutting-down-tomcat-via.html

策马西风 2024-11-24 04:20:28

我也有同样的问题。我无法从我的 Hudson 服务器停止容器,而它在我的本地计算机上正确停止,具有相同的 pom.xml 和相同的 Maven 目标和选项。

问题在于 Hudson 位于 Tomcat 上,并且容器和 Tomcat 使用相同的端口。将servlet端口从8080更改为8181,将AJP端口从8009更改为8012(数字任意选择)解决了问题,“停止”目标成功执行。

我必须更改 2 个端口,因为冲突发生在 2 个 Tomcat 之间,如果冲突发生在 Tomcat 和其他东西之间,则可能需要进行 2 个更改之一。

我用来更改端口的两行是:

<configuration>
     ...
     <properties>
        ...
        <cargo.servlet.port>8181</cargo.servlet.port>
        <cargo.tomcat.ajp.port>8012</cargo.tomcat.ajp.port>
        ...
    </properties>
    ...
</configuration>

I had the same problem. I couldn't stop the container from my Hudson server, while it was correctly stopping on my local machine with the same pom.xml and the same Maven goals and options.

The problem was that the Hudson was on a Tomcat, and the container and the Tomcat used the same ports. Changing the servlet port from 8080 to 8181, and the AJP port from 8009 to 8012 (numbers had been arbitrarily chosen) solved the problem, and the "stop" goal is successfully executed.

I had to change the 2 ports because the conflict was between 2 Tomcats, if the conflict is between a Tomcat and something else just one of the 2 changes could be necessary.

The 2 lines I used to change the ports are :

<configuration>
     ...
     <properties>
        ...
        <cargo.servlet.port>8181</cargo.servlet.port>
        <cargo.tomcat.ajp.port>8012</cargo.tomcat.ajp.port>
        ...
    </properties>
    ...
</configuration>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文