redeploy fails when <properties> element has <context>ROOT</context>
Description
Activity
Steve Lopez May 20, 2021 at 1:22 PM
Thank you - changing context to
/
worked!
p.s. yes, your understanding is correct that on test we want to overwrite the existing WAR but on production we want to utilize Tomcat's versioning mechanism so existing sessions continue running against the previous war
S. Ali Tokmen May 20, 2021 at 5:16 AM
Hi Steve
Thank you very much for your quick reply - Though indeed we are not at the resolution yet.
In production, when you want to have multiple versions, you indeed would need to deploy with ROOT##version
and wait until all sessions on the old version have finished, while in test you want to undeploy the old version ASAP. Is my understanding correct?
As for the information from the logs: would you mind setting the context to /
only (and not ROOT
)? I am suspecting that’s what confusing the deployer: normally, Codehaus Cargo expects that a context called ROOT
implies the application is on /ROOT
.
Regards
Steve Lopez May 19, 2021 at 8:59 PMEdited
Thank you for the quick reply. This issue occurred on 1.9.3 as well.
I just tried the following mvn command and still get the error. here is the output
mvn cargo:redeploy -X -Dcontext=ROOT -Dcargo.tomcat.undeploy.allVersions=true
Note: the -Dcontext=ROOT gets translated by the pom via the following:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven3-plugin</artifactId>
<version>1.9.4</version>
<configuration>
<container>
<containerId>tomcat9x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.server.settings>${target}</cargo.server.settings>
</properties>
</configuration>
<deployables>
<deployable>
<groupId>XXXX.XXXXX</groupId>
<artifactId>XXXXX</artifactId>
<type>war</type>
<properties>
<context>${context}</context>
</properties>
</deployable>
</deployables>
</configuration>
</plugin>
Note: I’m assuming the undeploy.AllVersions can be setup as a property in the cargo deployable section of the POM too but I wouldn’t want to put it there since this is also used to deploy on the production system, where we want the old ##{version#} war file to continue until those sessions are drained
Here is the output:
36865 [DEBUG] [ternal.TomcatManager] Invoking Tomcat manager using path [/deploy?path=%2FROOT]
36866 [DEBUG] [ternal.TomcatManager] Performing PUT request
37872 [INFO] ------------------------------------------------------------------------
37872 [INFO] BUILD FAILURE
37872 [INFO] ------------------------------------------------------------------------
37873 [INFO] Total time: 36.908 s
37873 [INFO] Finished at: 2021-05-19T13:52:26-07:00
37873 [INFO] ------------------------------------------------------------------------
37875 [ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven3-plugin:1.9.4:redeploy (default-cli) on project usrowing: Execution default-cli of goal org.codehaus.cargo:cargo-maven3-plugin:1.9.4:redeploy failed: Failed to deploy [/home/gitlab-runner/builds/cHLuSyYo/0/US/USRowing-Membership-Portal/target/usrowing-MASTER-BUILD-SNAPSHOT.war]: Error writing request body to server -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.cargo:cargo-maven3-plugin:1.9.4:redeploy (default-cli) on project usrowing: Execution default-cli of goal org.codehaus.cargo:cargo-maven3-plugin:1.9.4:redeploy failed: Failed to deploy [/home/gitlab-runner/builds/cHLuSyYo/0/US/USRowing-Membership-Portal/target/usrowing-MASTER-BUILD-SNAPSHOT.war]
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.codehaus.cargo:cargo-maven3-plugin:1.9.4:redeploy failed: Failed to deploy [/home/gitlab-runner/builds/cHLuSyYo/0/US/USRowing-Membership-Portal/target/usrowing-MASTER-BUILD-SNAPSHOT.war]
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.codehaus.cargo.container.ContainerException: Failed to deploy [/home/gitlab-runner/builds/cHLuSyYo/0/US/USRowing-Membership-Portal/target/usrowing-MASTER-BUILD-SNAPSHOT.war]
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy (AbstractTomcatManagerDeployer.java:110)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy (AbstractTomcatManagerDeployer.java:180)
at org.codehaus.cargo.maven3.DeployerRedeployMojo.performDeployerActionOnSingleDeployable (DeployerRedeployMojo.java:49)
at org.codehaus.cargo.maven3.AbstractDeployerMojo.performDeployerActionOnAllDeployables (AbstractDeployerMojo.java:168)
at org.codehaus.cargo.maven3.AbstractDeployerMojo.doExecute (AbstractDeployerMojo.java:98)
at org.codehaus.cargo.maven3.AbstractCargoMojo.execute (AbstractCargoMojo.java:439)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.io.IOException: Error writing request body to server
at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.checkError (HttpURLConnection.java:3653)
at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write (HttpURLConnection.java:3636)
at java.io.BufferedOutputStream.write (BufferedOutputStream.java:123)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke (TomcatManager.java:565)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deployImpl (TomcatManager.java:772)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deploy (TomcatManager.java:286)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy (AbstractTomcatManagerDeployer.java:105)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy (AbstractTomcatManagerDeployer.java:180)
at org.codehaus.cargo.maven3.DeployerRedeployMojo.performDeployerActionOnSingleDeployable (DeployerRedeployMojo.java:49)
at org.codehaus.cargo.maven3.AbstractDeployerMojo.performDeployerActionOnAllDeployables (AbstractDeployerMojo.java:168)
at org.codehaus.cargo.maven3.AbstractDeployerMojo.doExecute (AbstractDeployerMojo.java:98)
at org.codehaus.cargo.maven3.AbstractCargoMojo.execute (AbstractCargoMojo.java:439)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
37893 [ERROR]
37893 [ERROR]
37894 [ERROR] For more information about the errors and possible solutions, please read the following articles:
37894 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
ERROR: Job failed: exit status 1
S. Ali Tokmen May 19, 2021 at 7:44 PM
Hi Steve
This is bizarre - I would have 3 questions:
Did this work with Codehaus Cargo 1.9.3?
Did you try the
cargo.tomcat.undeploy.allVersions
option, so the previous versions in your test environment are undeployed?Would it be possible for you to run
mvn
with the-X
option (so we have the detailed logs) and attach it to the ticket? In particular, theTomcatManager
-related logs would be interesting…
Regards
Steve Lopez May 19, 2021 at 12:45 PMEdited
p.s. the work around temporarily is to change the deploy to mvn:deploy
and use a context value such as ROOT##${CI_PIPELINE_ID}
(But this creates headaches for testing since existing sessions will be served using the old version of the war making it necessary to expire those sessions manually.
On our production systems we use Tomcat versioning with the
##
suffix to allow for deploys that don't interrupt existing sessions. For that we usecargo:deploy
and it works fine.On our test server we would prefer to overwrite the existing war file using
cargo:redeploy
. This works fine when we use a value other thanROOT
as the<context>
attribute. For when we use ROOT we see the following error:Caused by: java.io.IOException: Error writing request body to server at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.checkError (HttpURLConnection.java:3653) at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write (HttpURLConnection.java:3636) at java.io.BufferedOutputStream.write (BufferedOutputStream.java:123) at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke (TomcatManager.java:565) at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deployImpl (TomcatManager.java:772) at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deploy (TomcatManager.java:286) at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy (AbstractTomcatManagerDeployer.java:105) at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy (AbstractTomcatManagerDeployer.java:180) at org.codehaus.cargo.maven3.DeployerRedeployMojo.performDeployerActionOnSingleDeployable (DeployerRedeployMojo.java:49) at org.codehaus.cargo.maven3.AbstractDeployerMojo.performDeployerActionOnAllDeployables (AbstractDeployerMojo.java:168) at org.codehaus.cargo.maven3.AbstractDeployerMojo.doExecute (AbstractDeployerMojo.java:98) at org.codehaus.cargo.maven3.AbstractCargoMojo.execute (AbstractCargoMojo.java:439) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:566) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)