异常错误:org.apache.zookeeper.admin.ZooKeeperAdmin

nnt7mjpx  于 2022-12-09  发布在  Apache
关注(0)|答案(1)|浏览(1245)

I had a zookeeper with version 3.4.10 and curator with version 2.12.0 but zookeeper with versions less than 3.5.8 has a strict transitive dependency on log4j1. I would like to use log4j2 that's why it's require to update zookeeper version. I tried different combinations:

  1. zookeeper 3.6.1 and curator 5.1.0
  2. zookeeper 3.5.9 and curator 5.1.0
  3. zookeeper 3.5.9 and curator 5.0.0
  4. zookeeper 3.5.9 and curator 5.1.0 + exclude zookeeper dependency from curator
  5. zookeeper 3.5.9 and curator 4.3.0 + exclude zookeeper dependency from curator
  6. zookeeper 3.6.1 and curator 5.1.0 + exclude zookeeper dependency from curator
    All of these options fail. 1 option is failing with the following stacktrace:
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 options look like has the same stracktrace:

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)

Actually, ZooKeeperAdmin class presents in Zookeeper since 3.5.7 that's why it's strange why it cannot be found.
Could someone suggest any ideas? Is it an issue with dependencies versions (I couldn't find any details for zk > 3.4 with curator)? Or any way to debug and get understanding of this issue?

vaqhlq81

vaqhlq811#

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

and refer to the pr https://github.com/apache/zookeeper/pull/1285
So you may have two methods to solve this problem.

  1. downgrade the zookeeper version to 3.4.13, and using curator 4.2.0, please refer to https://curator.apache.org/zk-compatibility-34.html .
  2. upgrade the curator to 5.2.1 and upgrade the env of zookeeper which needs 3.6.1 above.

相关问题