Home > Software design >  package org.slf4j does not exist when updating spring-kafka
package org.slf4j does not exist when updating spring-kafka

Time:11-16

We are attempting to make some updates to our app. We are using a build.gradle file and updated our org.springframework.kafka:spring-kafka to 2.8.0 from 2.7.14.

However, when doing this update we get the following error for code that uses lombok logging :

error: package org.slf4j does not exist

This is confusing because we did not touch lombok. Here is the declaration :

compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'

I checked the spring-kafka website for updates to see if there are compatibility issues, but found nothing. Unsure on where to look for this problem, if anyone could help. We are using java 17 if that helps.

Thank you

CodePudding user response:

Why are you moving to 2.8.0? The current 2.8.x version is 2.8.10 (and 2.8.x goes out of OSS support today).

https://spring.io/projects/spring-kafka#learn

https://spring.io/projects/spring-kafka#support

I would recommend going straight to 2.9.2.

It looks like you were relying on a transitive dependency of the kafka-clients...

2.7.x

compileClasspath - Compile classpath for compilation 'main' (target  (jvm)).
 --- org.springframework:spring-context -> 5.3.20
|     --- org.springframework:spring-aop:5.3.20
|    |     --- org.springframework:spring-beans:5.3.20
|    |    |    \--- org.springframework:spring-core:5.3.20
|    |    |         \--- org.springframework:spring-jcl:5.3.20
|    |    \--- org.springframework:spring-core:5.3.20 (*)
|     --- org.springframework:spring-beans:5.3.20 (*)
|     --- org.springframework:spring-core:5.3.20 (*)
|    \--- org.springframework:spring-expression:5.3.20
|         \--- org.springframework:spring-core:5.3.20 (*)
 --- org.springframework:spring-messaging -> 5.3.20
|     --- org.springframework:spring-beans:5.3.20 (*)
|    \--- org.springframework:spring-core:5.3.20 (*)
 --- org.springframework:spring-tx -> 5.3.20
|     --- org.springframework:spring-beans:5.3.20 (*)
|    \--- org.springframework:spring-core:5.3.20 (*)
 --- org.springframework.retry:spring-retry:1.3.3
 --- org.apache.kafka:kafka-clients:2.7.2
|     --- com.github.luben:zstd-jni:1.4.5-6
|     --- org.lz4:lz4-java:1.7.1
|     --- org.xerial.snappy:snappy-java:1.1.7.7
|    \--- org.slf4j:slf4j-api:1.7.30
 --- com.google.code.findbugs:jsr305:3.0.2
...

Newer kafka-clients only have it on the runtime class path.

2.8.x

compileClasspath - Compile classpath for compilation 'main' (target  (jvm)).
 --- org.springframework:spring-context -> 5.3.23
|     --- org.springframework:spring-aop:5.3.23
|    |     --- org.springframework:spring-beans:5.3.23
|    |    |    \--- org.springframework:spring-core:5.3.23
|    |    |         \--- org.springframework:spring-jcl:5.3.23
|    |    \--- org.springframework:spring-core:5.3.23 (*)
|     --- org.springframework:spring-beans:5.3.23 (*)
|     --- org.springframework:spring-core:5.3.23 (*)
|    \--- org.springframework:spring-expression:5.3.23
|         \--- org.springframework:spring-core:5.3.23 (*)
 --- org.springframework:spring-messaging -> 5.3.23
|     --- org.springframework:spring-beans:5.3.23 (*)
|    \--- org.springframework:spring-core:5.3.23 (*)
 --- org.springframework:spring-tx -> 5.3.23
|     --- org.springframework:spring-beans:5.3.23 (*)
|    \--- org.springframework:spring-core:5.3.23 (*)
 --- org.springframework.retry:spring-retry:1.3.4
 --- org.apache.kafka:kafka-clients:3.0.2
 --- com.google.code.findbugs:jsr305:3.0.2
...
  • Related