Cannot deploy locally using Cargo plugin for Gradle

1k views Asked by At

I'm having some problem to deploy a Java application using Cargo plugin for Gradle.

I've tried to add commons-discovery and commons-logging as dependencies but it didn't work as well.

:build
:copyWarToTomcat
:removeSymLinks
:removeExplodedWar UP-TO-DATE
:cargoRunLocal FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':cargoRunLocal'.
> Could not create type cargo due to java.lang.NoClassDefFoundError: org/apache/commons/discovery/resource/ClassLoaders

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':cargoRunLocal'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)

BUILD FAILED

This is the cargo dependency in my build.gradle:

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

And this is the localDeploy.gradle where I added the Cargo config:

apply plugin: 'com.bmuschko.cargo'

cargo {
    containerId = 'tomcat7x'

    local {
        installer {
            installUrl = 'https://archive.apache.org/dist/tomcat/tomcat-7/v7.0.67/bin/apache-tomcat-7.0.67.zip'
            downloadDir = file("$buildDir/download")
            extractDir = file("$buildDir/extract")
        }
    }
}
2

There are 2 answers

0
Pankaj Pandey On

It seems common discovery jar file not loaded properly.

I guess you should enable org.gradle.debug=true in gradle.properties and try debuging it - When set to true, Gradle will run the build with remote debugging enabled, listening on port 5005. Note that this is the equivalent of adding -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 to the JVM command line and will suspend the virtual machine until a debugger is attached.

0
abcdef On

Make sure the dependencies are transitive if you have the below then make it more specific

configurations.all {
    transitive = false
}

example

configurations.compile {
    transitive = false
}

This way gradle will download all the dependencies for cargo