Apache Phoenix JDBC报错NoClassDefFoundError: org/cloudera/htrace/Sampler求助
Hey there! That NoClassDefFoundError is telling us exactly what's missing—your project doesn't have the Jar that contains the org.cloudera.htrace.Sampler class.
The Missing Jar
You need the htrace-core4 Jar package (or a version compatible with your Phoenix release). This class is part of the HTrace library, which Phoenix relies on for tracing-related functionality under the hood.
How to Fix It
If you're using Maven:
Add this dependency to your pom.xml (make sure the version matches your Phoenix version—for example, Phoenix 5.x typically pairs with htrace-core4 4.2.0-incubating):
<dependency> <groupId>org.apache.htrace</groupId> <artifactId>htrace-core4</artifactId> <version>4.2.0-incubating</version> <scope>runtime</scope> </dependency>
If you're manually managing Jars:
Download the appropriate htrace-core4 Jar (matching your Phoenix version) and add it to your project's classpath. Double-check that you're using a version compatible with your Phoenix JDBC driver to avoid version conflicts that could cause other unexpected errors.
Quick Tip
Always keep all your Phoenix-related dependencies (JDBC driver, htrace, etc.) on the same version line—mixing mismatched versions is a common source of classpath issues like this one.
内容的提问来源于stack exchange,提问作者Ranit Dholey

