Gradle cargoRunLocal 0% in command prompat

I have created war and trying to deploy to local tomcat.When i am running gradle cargoRunLocal .
Command prompt displaying message
Building 0% : cargoLocalRun

apply plugin: 'java’
apply plugin: 'eclipse’
apply plugin: 'war’
apply plugin: ‘com.bmuschko.cargo’

sourceCompatibility = 1.7

buildscript {

repositories {
    maven {
        url "https://plugins.grdev.net/m2/"
    }
}

dependencies {
    classpath 'com.bmuschko:gradle-cargo-plugin:2.2'
}

}

repositories {
mavenCentral()
}

dependencies {

def cargoVersion = '1.4.5'
cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion",
      "org.codehaus.cargo:cargo-ant:$cargoVersion"

}

cargo {
containerId = ‘tomcat7x’
port = 8080
println(“start”)
deployable {
context = ‘userregisteration’
// file = file(’/Users/me/Documents/gradlemucks/grails_2/hello-world/target/hello-world-0.1.war’)
file = file(‘C:/Users/naresh.vatsal/workspace_spring_jan14/userregisteration/build/libs/userregisteration.war’)

   }
  local {
           homeDir = file('C:/soft/apache-tomcat-7.0.67')
           outputFile = file('C:/soft/apache-tomcat-7.0.67/output.log')
          containerProperties {
        property 'cargo.tomcat.ajp.port', 9099
         }
    }  

}

The documentation of the plugin states the following:

cargoRunLocal - “Starts the local container, deploys a deployable and waits for the user to press CTRL + C to stop.”

The task you are using deploys the WAR file to the container, starts the container and waits for you to stop it after using the container.

I’d recommend watching this video. It explains the tasks of the plugin and their use cases in detail.

I checked video and blog , i am following steps as per instruction.My script is like below.My war is already available. Neither War is not copied to tomcat not tomcat started.
I am using jdk 1.7, gradle 2.8
cargo {
containerId = 'tomcat7x’
port = 8080
println(“start”)
deployable {
context = 'userregisteration’
file = file(‘C:/Users/naresh.vatsal/workspace_spring_jan14/userregisteration/build/libs/userregisteration.war’)

   }
  local {
     homeDir = file('C:/soft/apache-tomcat-7.0.67')
     outputFile = file('C:/soft/apache-tomcat-7.0.67/output.log')
      containerProperties {
        property 'cargo.tomcat.ajp.port', 9099
         }
    }  

}

Please provide a sample project on Github that reproduces your issue including the checked-in Wrapper.

Now i changed my script ,after running gradle cragoLocalRun getting below error
FAILURE: Build failed with an exception.

  • What went wrong:
    Could not read entry ‘:cargoRunLocal’ from cache taskArtifacts.bin (C:\Users\naresh.vatsal\workspace_spring_jan14\userregisteration.gradle\2.8\taskArtifacts\ta
    skArtifacts.bin).

com.bmuschko.gradle.cargo.convention.ZipUrlInstaller; local class incompatible: stream classdesc serialVersionUID = -1368481122336730923, local class serialVe
rsionUID = 5549252188911634944

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 6.744 secs

apply plugin: ‘java’
apply plugin: ‘eclipse’
apply plugin: ‘com.bmuschko.cargo’

sourceCompatibility = 1.7

buildscript {

repositories {
    jcenter()
}

dependencies {
    classpath 'com.bmuschko:gradle-cargo-plugin:2.2.1'
}

}
dependencies {

def cargoVersion = '1.4.5'
cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion",
      "org.codehaus.cargo:cargo-ant:$cargoVersion"

}

cargo {
containerId = ‘tomcat7x’
port = 8080
println(“start”)
deployable {
context = ‘userregisteration’
file = file(‘C:/Users/naresh.vatsal/workspace_spring_jan14/userregisteration/build/libs/userregisteration.war’)

   }
  local {
     homeDir = file('C:/soft/apache-tomcat-7.0.67')
     outputFile = file('C:/soft/apache-tomcat-7.0.67/output.log')
      containerProperties {
        property 'cargo.tomcat.ajp.port', 9099
         }
    }  

}

Just the build script won’t help. I’d also need the code that’s bundled in the WAR file.

Note: Could you please also make sure to properly format your code in your posts? It’s really hard to read.

Thanks Benjamin,
i tried to upload code to github, but not able to complete.
So i have uploaded the code to google drive.
Please find link for downloading

https://drive.google.com/file/d/0BzlJ8UJY57CCbWRCZkhoaEVXUVU/view?usp=sharing

it is java dynamic web project created in eclipse mars

The container starts up properly for me (executed with gradle cargoRunLocal -i):

:cargoRunLocal
Executing task ':cargoRunLocal' (up-to-date check took 0.005 secs) due to:
  Task.upToDateWhen is false.
Deployable artifacts = [/Users/bmuschko/Downloads/userregisteration/build/libs/userregisteration.war]
Starting action 'run' for local container 'tomcat7x'
Container properties = [cargo.tomcat.ajp.port:9099]
System properties = [:]
Tomcat 7.x starting...
Deploying [/Users/bmuschko/Downloads/userregisteration/build/libs/userregisteration.war] to [/var/folders/wg/5w1qdscj105fzvs23ypkc2ym0000gn/T/cargo/conf/webapps]...
Tomcat 7.x started on port [8080]
[ant:cargo] Press Ctrl-C to stop the container...
Press Ctrl-C to stop the container...

I wasn’t sure what URL to hit that should actually serve up some content but Tomcat is running. What’s a valid URL that should work (please verify without Cargo first that it actually does work)?

Some things to keep in mind when using Cargo:

  • Cargo does not copy the WAR file to the webapps directory of Tomcat. So if you are looking for it there you won’t find it.
  • Cargo does not write the logs to the default Tomcat logs directory.

Hi Benjamin
You have copied war file manually to tomcat or cargo copied for build/lib folder to tomcat.
i changed deployable path from
file = file(‘D:/userregisteration/build/libs/userregisteration.war’)
to
file = file(‘/userregisteration/build/libs/userregisteration.war’)
suggest how file path should be given with drive name or starting with / e.g C:/user/userreg.war or /user/userreg.war

i am getting below error

  • What went wrong:
    Execution failed for task ‘:cargoRunLocal’.

Deployable D:\userregisteration\userregisteration\build\libs\userregisteration
.war does not exist

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --debug option to
    get more log output.

BUILD FAILED

Cargo does all the work for you. I did not copy it manually. As described in the documentation of the plugin, Cargo automatically determines the path to the WAR file. You don’t have to the value manually. Just remove the assignment from your configuration.

file: An arbitrary artifact or exploded WAR directory to be deployed to container (defaults to project/module artifact - WAR or EAR file).

Thanks Benjamin for your support, now i am able to deploy and run web app.

I need to keep tomcat in project directory then only my web app deploy.
Is it possible to keep tomcat outside project directory and provide same path in homDir. Please advise on this.

You can point the plugin to any location on your machine that hosts a Tomcat installation.

Hi Benjamin,

i changed homeDir = file(‘d/soft/apache-tomcat-7.0.67’) , but its concatenating path like below

[C:\Users\naresh.vatsal\workspace_spring_jan14\userregisteration\d\soft\apache-tomcat-7.0.67]

Can you please suggest what i need to chang in plugin to point to different tomcat instalaltion location other than project location.

Sorry I was wrong , i have given wrong path . Correct path is

homeDir = file(‘c:/soft/apache-tomcat-7.0.67’)

Now its deploying to external tomcat. Once again Benjamin thanks for your support.

Please see Gradle documentation on the file method for more information.