-1

i am trying to setup a simple gradle project for Apache Kafka POC. Please suggest how to resolve this.

stacktrace while building


Root cause: org.gradle.internal.resolve.ArtifactNotFoundException: Could not find jms.jar (javax.jms:jms:1.1).
Searched in the following locations:
    https://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.jar

This is the gradle file used for the project


apply plugin: 'java-library'


repositories {

     mavenCentral()
}

dependencies {
    api 'org.apache.commons:commons-math3:3.6.1'

    implementation 'com.google.guava:guava:23.0'

    testImplementation 'junit:junit:4.12'

    compile(group: 'org.apache.kafka', name: 'kafka_2.10', version: '0.8.0') 

    compile 'org.apache.kafka:kafka-clients:0.10.2.0'
}
Vaibhav Singh
  • 177
  • 10

1 Answers1

1

Problem is coming from the transitive library log4j-1.2.15 which belongs to zookeeper transitive libraries:

    +--- org.apache.kafka:kafka_2.10:0.8.0
|    +--- org.apache.zookeeper:zookeeper:3.3.4
|    |    +--- log4j:log4j:1.2.15
|    |    |    +--- javax.mail:mail:1.4
|    |    |    |    \--- javax.activation:activation:1.1
|    |    |    +--- javax.jms:jms:1.1
|    |    |    +--- com.sun.jdmk:jmxtools:1.2.1
|    |    |    \--- com.sun.jmx:jmxri:1.2.1
|    |    \--- jline:jline:0.9.94
|    |         \--- junit:junit:3.8.1

This log4j version has dependencies on other libraries which are not hosted on maven central repository (see What happened to JMS 1.1 in Maven Central?)

So you can add jcenter() repository

repositories {
    jcenter()
    mavenCentral()
}

But then you will have other issues with other transitive libs that you should exclude : either exclude log4j or jdmk and jmx from transitive dependencies as follows:

dependencies {
    api 'org.apache.commons:commons-math3:3.6.1'
    implementation 'com.google.guava:guava:23.0'
    testImplementation 'junit:junit:4.12'

    compile(group: 'org.apache.kafka', name: 'kafka_2.10', version: '0.8.0'){
        exclude group : "com.sun.jdmk"
        exclude group : "com.sun.jmx"

        // or simply exclude all  log4j:
        //  exclude group : "log4j"
    }
    compile 'org.apache.kafka:kafka-clients:0.10.2.0'
}

Mode details about issue with log4j 1.2.15 :http://unitstep.net/blog/2009/05/18/resolving-log4j-1215-dependency-problems-in-maven-using-exclusions/

M.Ricciuti
  • 11,070
  • 2
  • 34
  • 54