动物园管理员:java.lang.ClassNotFoundException:org.apache.zookeeper.admin.ZooKeeperAdmin

2024-04-18

我有一个版本为3.4.10的zookeeper和版本为2.12.0的curator,但版本低于3.5.8的zookeeper对log4j1有严格的传递依赖。 我想使用 log4j2 这就是为什么需要更新 Zookeeper 版本。我尝试了不同的组合:

  1. 动物园管理员 3.6.1 和策展人 5.1.0
  2. 动物园管理员 3.5.9 和策展人 5.1.0
  3. 动物园管理员 3.5.9 和策展人 5.0.0
  4. Zookeeper 3.5.9 和 curator 5.1.0 + 从 curator 中排除 Zookeeper 依赖项
  5. Zookeeper 3.5.9 和 curator 4.3.0 + 从 curator 中排除 Zookeeper 依赖项
  6. Zookeeper 3.6.1 和 curator 5.1.0 + 从 curator 中排除 Zookeeper 依赖项

所有这些选项都失败了。 1 个选项失败并出现以下堆栈跟踪:

 java.lang.NoSuchMethodError: org.apache.zookeeper.ZooKeeper.close(I)Z
 2021-04-05 14:22:19.633  WARN o.a.c.loader.WebappClassLoaderBase       The web application [ROOT] appears to have started a thread named [main-EventThread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.misc.Unsafe.park(Native Method)
 java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2044)
 java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
 org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:495)
2021-04-05 14:22:19.638 ERROR c.w.event.ApplicationFailedListener  ApplicationFailedEvent, possibly port is not available or analyze message above, application will be restarted

2-6 个选项看起来具有相同的堆栈跟踪:

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'zookeeperPropertySourceLocator' defined in org.springframework.cloud.zookeeper.config.ZookeeperConfigBootstrapConfiguration: Unsatisfied dependency  
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'curatorFramework' defined in org.springframework.cloud.zookeeper.ZookeeperAutoConfiguration: Bean instantiation via factory method failed; nested exception i ...
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.curator.framework.CuratorFramework]: Factory method 'curatorFramework' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/zookee
Caused by: java.lang.NoClassDefFoundError: org/apache/zookeeper/admin/ZooKeeperAdmin
    at org.apache.curator.framework.CuratorFrameworkFactory.<clinit>(CuratorFrameworkFactory.java:65)
Caused by: java.lang.ClassNotFoundException: org.apache.zookeeper.admin.ZooKeeperAdmin
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)   

实际上,ZooKeeperAdmin 类从 3.5.7 开始就出现在 Zookeeper 中,这就是为什么找不到它的原因。

有人可以提出任何想法吗?这是依赖项版本的问题吗(我找不到 zk > 3.4 与 curator 的任何详细信息)?或者有什么方法可以调试并了解这个问题?


you may need to check the env of the zookeeper version to whether has the class of org/apache/zookeeper/admin/ZooKeeperAdmin. As I checked the ISSUE of Zookeeper, found that the zookeeperAdmin was new in the below issue. https://issues.apache.org/jira/browse/ZOOKEEPER-3689 https://issues.apache.org/jira/browse/ZOOKEEPER-3689 enter image description here

并参考公关https://github.com/apache/zookeeper/pull/1285 https://github.com/apache/zookeeper/pull/1285

所以你可能有两种方法来解决这个问题。

  1. 将zookeeper版本降级到3.4.13,并使用curator 4.2.0,请参考https://curator.apache.org/zk-compatibility-34.html https://curator.apache.org/zk-compatibility-34.html.
  2. 将curator升级到5.2.1,并升级zookeeper的env,需要3.6.1以上。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

动物园管理员:java.lang.ClassNotFoundException:org.apache.zookeeper.admin.ZooKeeperAdmin 的相关文章

随机推荐