From 7b8dd3cd676b9e64be463bb4c944210a07d55120 Mon Sep 17 00:00:00 2001 From: xunliu Date: Mon, 23 Sep 2024 10:44:34 +0800 Subject: [PATCH] find class h2 driver --- authorizations/authorization-ranger/build.gradle.kts | 1 - catalogs/catalog-hadoop/build.gradle.kts | 2 +- .../storage/relational/database/H2Database.java | 6 ++++++ integration-test-common/build.gradle.kts | 1 + spark-connector/v3.3/spark/build.gradle.kts | 8 ++++++++ spark-connector/v3.4/spark/build.gradle.kts | 8 ++++++++ spark-connector/v3.5/spark/build.gradle.kts | 10 ++++++++-- 7 files changed, 32 insertions(+), 4 deletions(-) diff --git a/authorizations/authorization-ranger/build.gradle.kts b/authorizations/authorization-ranger/build.gradle.kts index a8e46e079b0..b9a4988658e 100644 --- a/authorizations/authorization-ranger/build.gradle.kts +++ b/authorizations/authorization-ranger/build.gradle.kts @@ -68,7 +68,6 @@ dependencies { testImplementation(project(":catalogs:catalog-common")) testImplementation(project(":integration-test-common", "testArtifacts")) testImplementation(libs.mockito.core) - testImplementation(libs.h2db) testImplementation(libs.mysql.driver) testImplementation(libs.postgresql.driver) testImplementation("org.apache.spark:spark-hive_$scalaVersion:$sparkVersion") diff --git a/catalogs/catalog-hadoop/build.gradle.kts b/catalogs/catalog-hadoop/build.gradle.kts index 1ea30e10687..373d03dc5d9 100644 --- a/catalogs/catalog-hadoop/build.gradle.kts +++ b/catalogs/catalog-hadoop/build.gradle.kts @@ -71,7 +71,7 @@ dependencies { testImplementation(libs.minikdc) testImplementation(libs.hadoop3.minicluster) - + testImplementation(libs.bundles.metrics) testImplementation(libs.bundles.log4j) testImplementation(libs.mockito.core) testImplementation(libs.mockito.inline) diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/database/H2Database.java b/core/src/main/java/org/apache/gravitino/storage/relational/database/H2Database.java index 4214a9baeda..8cf205d41f2 100644 --- a/core/src/main/java/org/apache/gravitino/storage/relational/database/H2Database.java +++ b/core/src/main/java/org/apache/gravitino/storage/relational/database/H2Database.java @@ -54,6 +54,12 @@ public String startH2Database(Config config) { String connectionUrl = constructH2URI(originalJDBCUrl, storagePath); + try { + Class.forName("org.h2.Driver"); + } catch (ClassNotFoundException e) { + throw new RuntimeException("Failed to load H2 driver.", e); + } + try (Connection connection = DriverManager.getConnection(connectionUrl, username, password); Statement statement = connection.createStatement()) { String sqlContent = diff --git a/integration-test-common/build.gradle.kts b/integration-test-common/build.gradle.kts index d09314a957b..6e239e6e042 100644 --- a/integration-test-common/build.gradle.kts +++ b/integration-test-common/build.gradle.kts @@ -49,6 +49,7 @@ dependencies { testImplementation(libs.commons.io) testImplementation(libs.guava) testImplementation(libs.httpclient5) + testImplementation(libs.h2db) testImplementation(libs.testcontainers) testImplementation(libs.testcontainers.mysql) testImplementation(libs.testcontainers.postgresql) diff --git a/spark-connector/v3.3/spark/build.gradle.kts b/spark-connector/v3.3/spark/build.gradle.kts index 1d934459939..89eb240fea4 100644 --- a/spark-connector/v3.3/spark/build.gradle.kts +++ b/spark-connector/v3.3/spark/build.gradle.kts @@ -51,6 +51,14 @@ dependencies { exclude("org.apache.logging.log4j") exclude("org.slf4j") } + testImplementation(project(":server")) { + exclude("org.apache.logging.log4j") + exclude("org.slf4j") + } + testImplementation(project(":server-common")) { + exclude("org.apache.logging.log4j") + exclude("org.slf4j") + } testImplementation(project(":spark-connector:spark-common", "testArtifacts")) { exclude("com.fasterxml.jackson") } diff --git a/spark-connector/v3.4/spark/build.gradle.kts b/spark-connector/v3.4/spark/build.gradle.kts index 2494eaaa2fe..355a6006c06 100644 --- a/spark-connector/v3.4/spark/build.gradle.kts +++ b/spark-connector/v3.4/spark/build.gradle.kts @@ -52,6 +52,14 @@ dependencies { exclude("org.apache.logging.log4j") exclude("org.slf4j") } + testImplementation(project(":server")) { + exclude("org.apache.logging.log4j") + exclude("org.slf4j") + } + testImplementation(project(":server-common")) { + exclude("org.apache.logging.log4j") + exclude("org.slf4j") + } testImplementation(project(":spark-connector:spark-common", "testArtifacts")) { exclude("com.fasterxml.jackson") } diff --git a/spark-connector/v3.5/spark/build.gradle.kts b/spark-connector/v3.5/spark/build.gradle.kts index a8f8a44d02e..3e711a83b6f 100644 --- a/spark-connector/v3.5/spark/build.gradle.kts +++ b/spark-connector/v3.5/spark/build.gradle.kts @@ -53,11 +53,17 @@ dependencies { exclude("org.apache.logging.log4j") exclude("org.slf4j") } - testImplementation(project(":spark-connector:spark-common", "testArtifacts")) { - exclude("com.fasterxml.jackson") + testImplementation(project(":server")) { + exclude("org.apache.logging.log4j") + exclude("org.slf4j") + } + testImplementation(project(":server-common")) { exclude("org.apache.logging.log4j") exclude("org.slf4j") } + testImplementation(project(":spark-connector:spark-common", "testArtifacts")) { + exclude("com.fasterxml.jackson") + } testImplementation(libs.hive2.common) { exclude("com.sun.jersey")