# How do I deploy a .war to a remote container using the cargo plugin?

**URL:** <https://discuss.gradle.org/t/how-do-i-deploy-a-war-to-a-remote-container-using-the-cargo-plugin/6213>\
**Category:** Old Forum Archive\
**Created:** [November 4, 2013, 8:46pm UTC](https://discuss.gradle.org/t/how-do-i-deploy-a-war-to-a-remote-container-using-the-cargo-plugin/6213 "2013-11-04T20:46:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![J\_V](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@J\_V](https://discuss.gradle.org/u/J_V)\
**Post date:** [November 4, 2013, 8:46pm UTC](https://discuss.gradle.org/t/how-do-i-deploy-a-war-to-a-remote-container-using-the-cargo-plugin/6213/1 "2013-11-04T20:46:00Z")

</div>

I want to deploy a .war file to a remote container (a war that is not in my project but that I pass to Gradle as a param). I am using the cargo plugin, when I execute I get this error message and haven no idea what the message is referring to:

```gradle
Neither path nor baseDir may be null or empty string. path='' basedir='/home/projects/src/main/gradle'

```

I am not sure where I set ‘baseDir’ or ‘path’ and how this relates to the cargo plugin, there is nothing about those params in the documentation.

I am passing in (on the gradle command line)

```gradle
gradle -b <deployWar.gradle>
  -Phost=<myhost>
  -Pport=<my tomcat response port, not the ajp port>
  -PwarFileName=hello.war
  -Pweb_context=hello
  -Pscheme=http
  -q cargoDeployRemote

```

This is my cargo{} closure

```gradle
cargo {
    containerId = 'tomcat7x'
    port=port
   // <== the webapp response port, typically 8080, in this case it is not 8080
      deployable {
        file = file(warFileName)
        context = web_context
        // it would be very nice to specify a remote to use here (if I have multiple remotes)
    }
      remote {
// the deployable above knows this is the remote to use correct?, why is port not specified here?
        protocol=scheme
        hostname=host
        username=tomcat
        password=admin
    }
}

```

Does anyone anywhere have an example of deploying a .war to a remote container where the ajp port has been changed? Are wars deployed via the http response port? How is this possible?

---

<div class="post-metadata">

**Author:** ![J\_V](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@J\_V](https://discuss.gradle.org/u/J_V)\
**Post date:** [November 4, 2013, 11:51pm UTC](https://discuss.gradle.org/t/how-do-i-deploy-a-war-to-a-remote-container-using-the-cargo-plugin/6213/2 "2013-11-04T23:51:00Z")

</div>

I believe the problem is due to a bug in the cargo plugin, the port i pass in my cargo{} closure is not being honored, the plugin is forcing 8080 to be the port used and not reading the config. If the cargo code is grep’d for “8080”, the issue will be found.

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [November 5, 2013, 3:10am UTC](https://discuss.gradle.org/t/how-do-i-deploy-a-war-to-a-remote-container-using-the-cargo-plugin/6213/3 "2013-11-05T03:10:00Z")

</div>

‘port = port’ is a self-assignment and won’t have any effect. Try ‘port = project.port’.

---

<div class="post-metadata">

**Author:** ![J\_V](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@J\_V](https://discuss.gradle.org/u/J_V)\
**Post date:** [November 5, 2013, 5:26pm UTC](https://discuss.gradle.org/t/how-do-i-deploy-a-war-to-a-remote-container-using-the-cargo-plugin/6213/4 "2013-11-05T17:26:00Z")

</div>

I am still getting the same error message, it is not picking up the passed in port. My http response port is not 8080 but 9191. I have nothing running on port 8080. When I run gradle with --debug, I get

```gradle
10:25:11.682 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.net.ConnectException: Connection refused
10:25:11.682 [ERROR] [org.gradle.BuildExceptionReporter]
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:534)
10:25:11.682 [ERROR] [org.gradle.BuildExceptionReporter]
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deployImpl(TomcatManager.java:611)
10:25:11.682 [ERROR] [org.gradle.BuildExceptionReporter]
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deploy(TomcatManager.java:291)
10:25:11.683 [ERROR] [org.gradle.BuildExceptionReporter]
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy(AbstractTomcatManagerDeployer.java:102)
10:25:11.683 [ERROR] [org.gradle.BuildExceptionReporter]
... 71 more

```

Here is the info without running --debug ( just --info)

```gradle
:cargoDeployRemote (Thread[main,5,main]) started.
:cargoDeployRemote
Executing task ':cargoDeployRemote' (up-to-date check took 0.0 secs) due to:
  Task has not declared any outputs.
Container ID = tomcat7x
Deployable artifacts = [/home/projects/war/hello-1.0.0.war]
Starting action 'deploy' for remote container 'Tomcat 7.x' on 'http://<host>.com:8080'
Deploying [/home/projects/war/hello-1.0.0.war]
:cargoDeployRemote FAILED
:cargoDeployRemote (Thread[main,5,main]) completed. Took 0.866 secs.
  FAILURE: Build failed with an exception.
  * What went wrong:
Execution failed for task ':cargoDeployRemote'.
> org.codehaus.cargo.container.ContainerException: Failed to deploy [/home/projects/war/hello-1.0.0.war]
  * Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
  BUILD FAILED
  Total time: 8.816 secs

```

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [November 5, 2013, 5:28pm UTC](https://discuss.gradle.org/t/how-do-i-deploy-a-war-to-a-remote-container-using-the-cargo-plugin/6213/5 "2013-11-05T17:28:00Z")

</div>

Did you try with a project property named other than ‘port’, to rule out any conflicts? If that doesn’t help, I recommend to submit an issue for the Gradle Cargo plugin.
