Kafka with Zookeeper 3.5.7 Crash NoSuchMethodError: java.nio.ByteBuffer.flip()

Kafka with Zookeeper 3.5.7 Crash NoSuchMethodError: java.nio.ByteBuffer.flip()

我遇到了这个错误流

2020-03-10 13:43:33 NIOServerCnxnFactory [ERROR] Thread Thread[NIOWorkerThread-7,5,main] died
java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;
    at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:331)
    at org.apache.zookeeper.server.NIOServerCnxnFactory$IOWorkRequest.doWork(NIOServerCnxnFactory.java:530)
    at org.apache.zookeeper.server.WorkerService$ScheduledWorkRequest.run(WorkerService.java:155)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
...

使用 Java 版本

openjdk version "1.8.0_232"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_232-b09)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.232-b09, mixed mode)

我在本地 mac Os Catalina 上使用 zookeeper 3.5.7 启动 kafka 2.4.0 时遇到了这个问题,安装了自制软件。如何解决?

hazelcast and dopio 等其他服务中解释说,这是由 jdk 9 到 jdk 8 的向后兼容性问题引起的。

有 2 个明显的选项,您可以:

  1. 将您的 jdk 更新为 9

  2. 将您的动物园管理员降级为 3.4.x

我选择使用以下方式将我的动物园管理员降级为 3.4.14

# force install zookeeper first
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/6d8197bbb5f77e62d51041a3ae552ce2f8ff1344/Formula/zookeeper.rb

# then force install kafka compatible with zookeeper 3.4.14
brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/6d8197bbb5f77e62d51041a3ae552ce2f8ff1344/Formula/kafka.rb

brew uninstall zookeeper用brew卸载3.5.7的zookeeper,然后安装3.4.14的zookeeper

https://zookeeper.apache.org/releases.html or https://mirrors.cnnic.cn/apache/zookeeper

下载 link