1
votes

The jar amazon-kinesis-connectors is using amazon-kinesis-client. I want to change this dependency to a local custom jar:

dependencies {
    compile ('com.amazonaws:amazon-kinesis-connectors:1.2.0'){
        exclude group: "com.amazonaws", module: "amazon-kinesis-client"
    }
    compile files('libs/amazon-kinesis-client-1.6.3.jar')
//...
}

It compiles ok, but when I'm running the code I get java.lang.NoClassDefFoundError: com/amazonaws/services/kinesis/clientlibrary/interfaces/IRecordProcessorFactory. Is there a way to do this dependency management in gradle?

As environment I'm using:

  • gradle 2.13
  • intellij idea CE 2006.1
  • java 1.8

Edit:

dependency graph in intellij: enter image description here

Running using a gradle task:

task run_app(type:JavaExec) {
    main = 'org.main.RunApp'
    classpath = sourceSets.main.runtimeClasspath
}
1
This means, the jar is not included in the runtime package. Can you tell be if it is war or jar some other packaging and how the packaging is done. Also tell me how are you executing/runningSangram Jadhav
@SangramJadhav: I'm creating a jar using gradle build. I've edited the other details in the answer.djWann

1 Answers

1
votes

try below gradle configuration

dependencies {
    compile ('com.amazonaws:amazon-kinesis-connectors:1.2.0'){
        exclude group: "com.amazonaws", module: "amazon-kinesis-client"
    }
    compile files('libs/amazon-kinesis-client-1.6.3.jar')
    runtime files('libs/amazon-kinesis-client-1.6.3.jar')
    //...
}

or you can use application plugin to create executable jar

https://docs.gradle.org/current/userguide/userguide_single.html#application_plugin