Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZOOKEEPER-4910: fix error when no dep dropwizard java.lang.NoClassDefFoundError: com/… #2238

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

songxiaosheng
Copy link
Member

fix follow error

Exception in thread "ZooKeeper Server Starter" java.lang.NoClassDefFoundError: com/codahale/metrics/Reservoir
	at org.apache.zookeeper.metrics.impl.DefaultMetricsProvider$DefaultMetricsContext.lambda$getSummary$2(DefaultMetricsProvider.java:126)
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1713)
	at org.apache.zookeeper.metrics.impl.DefaultMetricsProvider$DefaultMetricsContext.getSummary(DefaultMetricsProvider.java:122)
	at org.apache.zookeeper.server.ServerMetrics.<init>(ServerMetrics.java:74)
	at org.apache.zookeeper.server.ServerMetrics.<clinit>(ServerMetrics.java:44)
	at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:133)
	at org.apache.dubbo.springboot.demo.provider.EmbeddedZooKeeper$ServerRunnable.run(EmbeddedZooKeeper.java:249)
	at java.base/java.lang.Thread.run(Thread.java:1575)
Caused by: java.lang.ClassNotFoundException: com.codahale.metrics.Reservoir
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:528)
	... 8 

@songxiaosheng
Copy link
Member Author

@tisonkun PATL

Copy link
Contributor

@cnauroth cnauroth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @songxiaosheng . Thank you for the patch, but I'm not sure we'll be able to commit this.

In #925 , we intentionally slimmed down pom.xml so that clients do not import dependencies that are only needed on the server side. Part of this included marking io.dropwizard.metrics:metrics-core as provided. This is only used on the ZooKeeper server side. If we commit this change, it's possible that actual failures in metrics initialization could leave a server running in production but not producing metrics.

From the sample stack trace, it looks like this is a use case for running ZooKeeper "embedded" as part of a demo application. In Apache Curator's tests, they handle this by explicitly adding their own dependency on io.dropwizard.metrics:metrics-core. Perhaps your demo application could do the same thing.

https://github.com/apache/curator/blob/apache-curator-5.8.0/curator-test/pom.xml#L45-L48

On a side note, you might also be interested in ZooKeeperServerEmbedded.

@songxiaosheng
Copy link
Member Author

Hello @songxiaosheng . Thank you for the patch, but I'm not sure we'll be able to commit this.

In #925 , we intentionally slimmed down pom.xml so that clients do not import dependencies that are only needed on the server side. Part of this included marking io.dropwizard.metrics:metrics-core as provided. This is only used on the ZooKeeper server side. If we commit this change, it's possible that actual failures in metrics initialization could leave a server running in production but not producing metrics.

From the sample stack trace, it looks like this is a use case for running ZooKeeper "embedded" as part of a demo application. In Apache Curator's tests, they handle this by explicitly adding their own dependency on io.dropwizard.metrics:metrics-core. Perhaps your demo application could do the same thing.

https://github.com/apache/curator/blob/apache-curator-5.8.0/curator-test/pom.xml#L45-L48

On a side note, you might also be interested in ZooKeeperServerEmbedded.

thanks, i found it in ZooKeeper "embedded"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants