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


(J.V.) #1

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:

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

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?


(J.V.) #2

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.


(Peter Niederwieser) #3

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


(J.V.) #4

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

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)

: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

(Peter Niederwieser) #5

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.