org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY]

By | May 12, 2024

I got the error message below in my java producer on Mac laptop

Error while sending .... message to Kafka with order id: ed2a21c3-3a5f-419b-b962-ff2e52f01d37, error: org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY] no native library is found for os.name=Mac and os.arch=aarch64

It happened on my laptop and I didn’t have time to investigate this so I just replaced ‘snappy’ compression-type value with ‘none’ in kafka producer configuration

kafka-producer-config:
  key-serializer-class: org.apache.kafka.common.serialization.StringSerializer
  value-serializer-class: io.confluent.kafka.serializers.KafkaAvroSerializer
  compression-type: none

A small reminder: compression is used on producer and consumer side to decrease size of trasfered data through additional CPU cicles on theirs sides for decompressing data. There are the following compression type algorithms:

  • none
  • gzip
  • snappy
  • lz4
  • zstd

Check this article for additional details related to compression configuration in kafka – https://www.confluent.io/blog/apache-kafka-message-compression/

Leave a Reply