-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Describe the Issue
I am using the GraalVM gradle plugin along with a combination of Spring and Reactive Kafka to connect to a kafka cluster and consume messages. The producer of the kafka messages is using ZSTD for compression which is supported by the Kafka library but at runtime produces this error:
Caused by: org.apache.kafka.common.KafkaException: java.lang.UnsatisfiedLinkError: No zstd-jni-1.5.6-4 in java.library.path
Unsupported OS/arch, cannot find /darwin/aarch64/libzstd-jni-1.5.6-4.dylib or load zstd-jni-1.5.6-4 from system libraries. Please try building from source the jar or providing libzstd-jni-1.5.6-4 in your system.
...
Caused by: java.lang.UnsatisfiedLinkError: No zstd-jni-1.5.6-4 in java.library.path
Unsupported OS/arch, cannot find /darwin/aarch64/libzstd-jni-1.5.6-4.dylib or load zstd-jni-1.5.6-4 from system libraries. Please try building from source the jar or providing libzstd-jni-1.5.6-4 in your system.
I've tried investigating why this file is not available at runtime and stumbled across this old issue luben/zstd-jni#115 in which some old metadata was added to the shared metadata repo for version 1.5.2-5
of which the version Kafka Reactive is using is 1.5.6-4
Nevertheless, even though the version I am using is 4 minor versions ahead, there are not that many differences, and I can see during compilation (after enabling logging) that it is correctly using it:
-H:ConfigurationFileDirectories@user=.../Users/user/.gradle/native-build-tools/repositories/ca03e6afc18d5c349f4c7ef6e0718cd42c0205ef/exploded/com.github.luben/zstd-jni/1.5.2-5
...
[thread:1] scope: main.registerResource
ResourcesFeature: registerResource: linux/amd64/libzstd-jni-1.5.6-4.so
I was wondering if you could assist in figuring out why this is the case?
Using the latest version of GraalVM can resolve many issues.
- I tried with the latest version of GraalVM.
GraalVM Version
openjdk version "21.0.2" 2024-01-16
OpenJDK Runtime Environment GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30)
OpenJDK 64-Bit Server VM GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30, mixed mode, sharing)
Operating System and Version
Darwin Kernel Version 23.6.0: Wed May 14 13:52:22 PDT 2025; root:xnu-10063.141.1.705.2~2/RELEASE_ARM64_T6000 arm64
This problem originally occurred when running on k8s using a regular AMD64 OS.
Troubleshooting Confirmation
- I tried the suggestions in the troubleshooting guide.
Run Command
./native-testing
Expected Behavior
The application is able to consume kafka messages using ZSTD compression
Actual Behavior
It throws a fatal exception when attempting to condume ZSTD compressed messages
Steps to Reproduce
See Additional Context
for repo where this is already set up
- Initialise Spring project with kafka
- Setup Kafka cluster and connect
- Send kafka message with zstd compression
Additional Context
I have created a repo to reproduce it here.
All information on how to run is in the README.md
Run-Time Log Output and Error Messages
Logs from AMD64
Unsupported OS/arch, cannot find /linux/amd64/libzstd-jni-1.5.6-4.so or load zstd-jni-1.5.6-4 from system libraries. Please try building from source the jar or providing libzstd-jni-1.5.6-4 in your system.
...
java.lang.NoClassDefFoundError: Could not initialize class com.github.luben.zstd.ZstdInputStreamNoFinalizer