Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#10508] fix(client-java-runtime): Exclude JDBC utils from shadow JAR to prevent NoClassDefFoundError (#11324)

Jerry Shao568121e90cb4
diff --git a/.gitignore b/.gitignore
index e085208f9f..036f1b3e67 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,8 @@ replay_pid*
!.idea/vcs.xml
**/.vscode
**/build
+# Zed editor's Java language server (Eclipse JDT) compiles classes into bin/ for code intelligence
+**/bin
gen
**/.DS_Store
**/*.iml
diff --git a/clients/client-java-runtime/build.gradle.kts b/clients/client-java-runtime/build.gradle.kts
index 01ca47724e..514f34e4e3 100644
--- a/clients/client-java-runtime/build.gradle.kts
+++ b/clients/client-java-runtime/build.gradle.kts
@@ -41,6 +41,14 @@ tasks.withType<ShadowJar>(ShadowJar::class.java) {
configurations = listOf(project.configurations.runtimeClasspath.get())
archiveClassifier.set("")
+ // Exclude server-side JDBC pooling utilities. These classes reference commons-dbcp2 which is
+ // declared compileOnly in :common and therefore never bundled here. Including them produces a
+ // broken relocated reference (BasicDataSource renamed to the shaded package, but the actual
+ // shaded class absent). Connector runtime JARs placed on Spark/Flink/Hadoop classpaths would
+ // then shadow the working copy in gravitino-jobs.jar via parent-first class delegation, causing
+ // NoClassDefFoundError at runtime. See https://github.com/apache/gravitino/issues/10508
+ exclude("org/apache/gravitino/utils/jdbc/**")
+
// Relocate dependencies to avoid conflicts
relocate("com.google", "org.apache.gravitino.shaded.com.google")
relocate("com.fasterxml", "org.apache.gravitino.shaded.com.fasterxml")