Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR: Build step failed with exception org.codehaus.cargo.container.ContainerException: Failed to redeploy

I have Jenkins installed on my AWS EC2 server, on which the following are installed:

  • Maven Integration Plugin
  • Deploy to Container Plugin
  • Slack Notification Plugin
  • GitHub Integration Plugin

... and possibly a few others I cannot remember (because coding)...

I create new freestyle Project, go to its config, and do the following:

  • In General, check GitHub project, and enter the Project url
  • In Source Code Management, select Git and enter the Repository URL
  • In Build Triggers, check GitHub hook trigger for GITScm polling
  • In Build, I add build step "Invoke top-level Maven targets", and do the following:
    • Enter clean install in Goals
    • Enter relative path of my project's pom.xml in POM
  • In Post-build Actions, I do the following:
    • Archive the artifacts: enter image description here
    • Deploy war/ear to container: idk what our business port is but from others, it was 8085

On my attempt to build the (working) code, it fails, and I get this long stack of info on the console:

Started by user Mike Warren
Building in workspace /home/ec2-user/.jenkins/workspace/Project2
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/MikeWarren2014/171106-Project2-SHOULDi.git # timeout=10
Fetching upstream changes from https://github.com/MikeWarren2014/171106-Project2-SHOULDi.git
 > git --version # timeout=10
 > git fetch --tags --progress https://github.com/MikeWarren2014/171106-Project2-SHOULDi.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision d172c840db59d7aff020787e0b49f3741f57b555 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f d172c840db59d7aff020787e0b49f3741f57b555
Commit message: "gamification finished"
 > git rev-list --no-walk d172c840db59d7aff020787e0b49f3741f57b555 # timeout=10
[Project2] $ mvn -f SHOULDi-back/pom.xml clean install
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building SHOULDi-back 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ SHOULDi-back ---
[INFO] Deleting /home/ec2-user/.jenkins/workspace/Project2/SHOULDi-back/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ SHOULDi-back ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ SHOULDi-back ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 49 source files to /home/ec2-user/.jenkins/workspace/Project2/SHOULDi-back/target/classes
[WARNING] /home/ec2-user/.jenkins/workspace/Project2/SHOULDi-back/src/main/java/com/zenith/DAO/UserDAO.java: Some input files use or override a deprecated API.
[WARNING] /home/ec2-user/.jenkins/workspace/Project2/SHOULDi-back/src/main/java/com/zenith/DAO/UserDAO.java: Recompile with -Xlint:deprecation for details.
[WARNING] /home/ec2-user/.jenkins/workspace/Project2/SHOULDi-back/src/main/java/com/zenith/DAO/UserDAO.java: Some input files use unchecked or unsafe operations.
[WARNING] /home/ec2-user/.jenkins/workspace/Project2/SHOULDi-back/src/main/java/com/zenith/DAO/UserDAO.java: Recompile with -Xlint:unchecked for details.
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ SHOULDi-back ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/ec2-user/.jenkins/workspace/Project2/SHOULDi-back/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ SHOULDi-back ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ SHOULDi-back ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-war-plugin:2.2:war (default-war) @ SHOULDi-back ---
[INFO] Packaging webapp
[INFO] Assembling webapp [SHOULDi-back] in [/home/ec2-user/.jenkins/workspace/Project2/SHOULDi-back/target/SHOULDi-back]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/ec2-user/.jenkins/workspace/Project2/SHOULDi-back/src/main/webapp]
[INFO] Webapp assembled in [293 msecs]
[INFO] Building war: /home/ec2-user/.jenkins/workspace/Project2/SHOULDi-back/target/SHOULDi-back.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ SHOULDi-back ---
[INFO] Installing /home/ec2-user/.jenkins/workspace/Project2/SHOULDi-back/target/SHOULDi-back.war to /home/ec2-user/.m2/repository/com/zenith/SHOULDi-back/1.0-SNAPSHOT/SHOULDi-back-1.0-SNAPSHOT.war
[INFO] Installing /home/ec2-user/.jenkins/workspace/Project2/SHOULDi-back/pom.xml to /home/ec2-user/.m2/repository/com/zenith/SHOULDi-back/1.0-SNAPSHOT/SHOULDi-back-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.207 s
[INFO] Finished at: 2017-12-31T00:24:46+00:00
[INFO] Final Memory: 19M/48M
[INFO] ------------------------------------------------------------------------
Archiving artifacts
Deploying /home/ec2-user/.jenkins/workspace/Project2/SHOULDi-back/target/SHOULDi-back.war to container Tomcat 7.x Remote with context Project2
ERROR: Build step failed with exception
org.codehaus.cargo.container.ContainerException: Failed to redeploy [/home/ec2-user/.jenkins/workspace/Project2/SHOULDi-back/target/SHOULDi-back.war]
    at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:192)
    at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:77)
    at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:147)
    at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:117)
    at hudson.FilePath.act(FilePath.java:997)
    at hudson.FilePath.act(FilePath.java:975)
    at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:114)
    at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeploy(PasswordProtectedAdapterCargo.java:93)
    at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:64)
    at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
    at hudson.model.Build$BuildExecution.post2(Build.java:186)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
    at hudson.model.Run.execute(Run.java:1749)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:421)
Caused by: java.net.ConnectException: Connection timed out (Connection timed out)
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
    at sun.net.www.http.HttpClient.New(HttpClient.java:339)
    at sun.net.www.http.HttpClient.New(HttpClient.java:357)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1220)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:984)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:561)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:876)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:889)
    at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:173)
    ... 17 more
java.net.ConnectException: Connection timed out (Connection timed out)

How can I fix this?

My tomcat credentials, located in [tomcat directory]/conf/tomcat-users.xml, are as follows:

<tomcat-users>
        <role rolename="manager-gui"/>
        <role rolename="manager-script"/>
        <user username="tomcatgui" password="password" roles="manager-gui" />
        <user username="project2" password="Z3n1th0x47726f7570" roles="manager-script" />
</tomcat-users>
like image 849
Mike Warren Avatar asked Feb 25 '26 19:02

Mike Warren


2 Answers

Since this is a connection time out,

  1. Check whether you restarted the tomcat instance after editing the tomcat-users.xml
  2. Check whether jenkins has access to tomcat instance.
  3. Whether the user credentials are correct
like image 96
Ishan Thilina Somasiri Avatar answered Feb 28 '26 08:02

Ishan Thilina Somasiri


For the same issue, setting port 8084 in server.xml and restarting the Apache worked for me. I replaced all occurrences of 8080 with 8084:

[root@ip-172-31-21-72 conf]# grep 8084 server.xml
     Define a non-SSL/TLS HTTP/1.1 Connector on port 8084
<Connector port="8084" protocol="HTTP/1.1"
           port="8084" protocol="HTTP/1.1"
like image 23
Gauraw Avatar answered Feb 28 '26 08:02

Gauraw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!