This is an automated email from the ASF dual-hosted git repository.
voonhous pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git
The following commit(s) were added to refs/heads/master by this push:
new bbe73d3e2ee4 fix: align log4j2 and slf4j versions to resolve IntelliJ
test failures (#18177)
bbe73d3e2ee4 is described below
commit bbe73d3e2ee4771b0fdaae39c7f5250e626c6c74
Author: Surya Prasanna <[email protected]>
AuthorDate: Mon Jul 13 03:08:27 2026 -0700
fix: align log4j2 and slf4j versions to resolve IntelliJ test failures
(#18177)
* Fix no classdef errors on intellij
* fix: bind slf4j 2.x by using the log4j-slf4j2-impl binding
Raising slf4j.version to 2.0.7 in the root properties leaves every build
that
does not activate a spark profile (a plain `mvn` build, and all -Dflink*
builds) pairing slf4j-api 2.0.7 with log4j-slf4j-impl. That artifact only
ships
org/slf4j/impl/StaticLoggerBinder, which is the slf4j 1.7 binding; slf4j 2.x
discovers providers through
META-INF/services/org.slf4j.spi.SLF4JServiceProvider
and therefore finds none:
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions
1.7.x
or earlier.
All logging would silently go to the NOP logger, which no test asserts on.
Swap the binding to log4j-slf4j2-impl (the log4j2 binding for slf4j 2.x,
available since log4j 2.19) in the root dependencyManagement, in every
module
that declares it, and in the hudi-metaserver-server-bundle shade includes.
Spark builds already pull log4j-slf4j2-impl transitively, so this only makes
the declared binding match what slf4j 2.x can actually load. No source
change
is needed: Hudi uses no slf4j 2.x-only API.
* fix: keep hive's slf4j 1.x binding off the classpath
hive-shims-common pulls in log4j-slf4j-impl 2.17.2, and that artifact ships
the
same classes as log4j-slf4j2-impl
(org.apache.logging.slf4j.Log4jLoggerFactory,
Log4jLogger, Log4jMarkerFactory), so both jars on one classpath means the
shared
classes are resolved from whichever jar comes first, with no Maven
mediation.
This was masked until now: the root dependencyManagement pinned
log4j-slf4j-impl
to ${log4j2.version}, so hive's copy was force-upgraded and its duplicate
Log4jLoggerFactory happened to carry the same (Log4jMarkerFactory)
constructor.
Once that entry became log4j-slf4j2-impl the pin was gone, hive's 2.17.2
copy
came in with only a no-arg constructor, and
SLF4JServiceProvider.initialize()
failed with
NoSuchMethodError: Log4jLoggerFactory.<init>(Log4jMarkerFactory)
surfacing as ExceptionInInitializerError / NoClassDefFoundError on every
class
with a static logger, e.g. HoodieConfig.
Exclude log4j-slf4j-impl from the four hive deps that leak it (hive-shims,
hive-jdbc, hive-serde, hive-metastore); hive-exec, hive-common and
hive-service
already exclude org.apache.logging.log4j:* wholesale. This mirrors the
existing
exclusions for slf4j-log4j12, hive's other slf4j 1.x binding.
* fix: keep spark 3.3's slf4j 1.x binding off the classpath
Spark only moved to log4j-slf4j2-impl in 3.4, so spark-core 3.3.x still
brings
log4j-slf4j-impl. That is the same duplicate-class collision already fixed
for
hive: both binding artifacts ship
org.apache.logging.slf4j.Log4jLoggerFactory,
so the older copy shadows the one log4j-slf4j2-impl expects and
SLF4JServiceProvider.initialize() dies with
NoSuchMethodError: Log4jLoggerFactory.<init>(Log4jMarkerFactory)
Exclude log4j-slf4j-impl from both spark-core entries in
dependencyManagement
(the main one and the tests classifier), alongside the org.slf4j:* and
log4j:log4j exclusions already there. Spark 3.4+ is unaffected: it ships the
slf4j2 binding already.
Verified there is no remaining log4j-slf4j-impl on the tree for spark3.3,
spark3.4, spark3.5, spark4.0, spark4.1, spark4.2, flink1.18, flink1.19,
flink1.20, flink2.0, flink2.1 and the default profile.
---------
Co-authored-by: voon <[email protected]>
---
hudi-client/hudi-flink-client/pom.xml | 2 +-
hudi-flink-datasource/hudi-flink/pom.xml | 2 +-
hudi-flink-datasource/hudi-flink1.18.x/pom.xml | 2 +-
hudi-flink-datasource/hudi-flink1.19.x/pom.xml | 2 +-
hudi-flink-datasource/hudi-flink1.20.x/pom.xml | 2 +-
hudi-flink-datasource/hudi-flink2.0.x/pom.xml | 2 +-
hudi-flink-datasource/hudi-flink2.1.x/pom.xml | 2 +-
hudi-io/pom.xml | 2 +-
hudi-platform-service/hudi-metaserver/pom.xml | 2 +-
hudi-sync/hudi-adb-sync/pom.xml | 2 +-
hudi-tests-common/pom.xml | 2 +-
packaging/hudi-metaserver-server-bundle/pom.xml | 4 +--
pom.xml | 34 +++++++++++++++++++++++--
13 files changed, 45 insertions(+), 15 deletions(-)
diff --git a/hudi-client/hudi-flink-client/pom.xml
b/hudi-client/hudi-flink-client/pom.xml
index 1f85446cd850..e6bfa2a06568 100644
--- a/hudi-client/hudi-flink-client/pom.xml
+++ b/hudi-client/hudi-flink-client/pom.xml
@@ -42,7 +42,7 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
+ <artifactId>log4j-slf4j2-impl</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git a/hudi-flink-datasource/hudi-flink/pom.xml
b/hudi-flink-datasource/hudi-flink/pom.xml
index bee3621645ef..5f420d4e67db 100644
--- a/hudi-flink-datasource/hudi-flink/pom.xml
+++ b/hudi-flink-datasource/hudi-flink/pom.xml
@@ -77,7 +77,7 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
+ <artifactId>log4j-slf4j2-impl</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git a/hudi-flink-datasource/hudi-flink1.18.x/pom.xml
b/hudi-flink-datasource/hudi-flink1.18.x/pom.xml
index ae8610a23913..61e924c0b763 100644
--- a/hudi-flink-datasource/hudi-flink1.18.x/pom.xml
+++ b/hudi-flink-datasource/hudi-flink1.18.x/pom.xml
@@ -40,7 +40,7 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
+ <artifactId>log4j-slf4j2-impl</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git a/hudi-flink-datasource/hudi-flink1.19.x/pom.xml
b/hudi-flink-datasource/hudi-flink1.19.x/pom.xml
index bc70bb5e96b1..97b8c9faff00 100644
--- a/hudi-flink-datasource/hudi-flink1.19.x/pom.xml
+++ b/hudi-flink-datasource/hudi-flink1.19.x/pom.xml
@@ -40,7 +40,7 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
+ <artifactId>log4j-slf4j2-impl</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git a/hudi-flink-datasource/hudi-flink1.20.x/pom.xml
b/hudi-flink-datasource/hudi-flink1.20.x/pom.xml
index 266d472efade..74ea840a65c9 100644
--- a/hudi-flink-datasource/hudi-flink1.20.x/pom.xml
+++ b/hudi-flink-datasource/hudi-flink1.20.x/pom.xml
@@ -40,7 +40,7 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
+ <artifactId>log4j-slf4j2-impl</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git a/hudi-flink-datasource/hudi-flink2.0.x/pom.xml
b/hudi-flink-datasource/hudi-flink2.0.x/pom.xml
index 770b92a94bc1..b19daa884953 100644
--- a/hudi-flink-datasource/hudi-flink2.0.x/pom.xml
+++ b/hudi-flink-datasource/hudi-flink2.0.x/pom.xml
@@ -40,7 +40,7 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
+ <artifactId>log4j-slf4j2-impl</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git a/hudi-flink-datasource/hudi-flink2.1.x/pom.xml
b/hudi-flink-datasource/hudi-flink2.1.x/pom.xml
index 93572a63363f..ac7fc0a87082 100644
--- a/hudi-flink-datasource/hudi-flink2.1.x/pom.xml
+++ b/hudi-flink-datasource/hudi-flink2.1.x/pom.xml
@@ -46,7 +46,7 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
+ <artifactId>log4j-slf4j2-impl</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git a/hudi-io/pom.xml b/hudi-io/pom.xml
index 53291379cff9..ab81623db959 100644
--- a/hudi-io/pom.xml
+++ b/hudi-io/pom.xml
@@ -185,7 +185,7 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
+ <artifactId>log4j-slf4j2-impl</artifactId>
<version>${log4j2.version}</version>
<scope>provided</scope>
</dependency>
diff --git a/hudi-platform-service/hudi-metaserver/pom.xml
b/hudi-platform-service/hudi-metaserver/pom.xml
index 0e1c3d3be11b..c3993a3b3b29 100644
--- a/hudi-platform-service/hudi-metaserver/pom.xml
+++ b/hudi-platform-service/hudi-metaserver/pom.xml
@@ -77,7 +77,7 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
+ <artifactId>log4j-slf4j2-impl</artifactId>
<version>${log4j2.version}</version>
<scope>compile</scope>
</dependency>
diff --git a/hudi-sync/hudi-adb-sync/pom.xml b/hudi-sync/hudi-adb-sync/pom.xml
index 78598a49fcc9..b3c008333a3c 100644
--- a/hudi-sync/hudi-adb-sync/pom.xml
+++ b/hudi-sync/hudi-adb-sync/pom.xml
@@ -103,7 +103,7 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
+ <artifactId>log4j-slf4j2-impl</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git a/hudi-tests-common/pom.xml b/hudi-tests-common/pom.xml
index 4a7a4f145b83..85f031cf2a37 100644
--- a/hudi-tests-common/pom.xml
+++ b/hudi-tests-common/pom.xml
@@ -68,7 +68,7 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
+ <artifactId>log4j-slf4j2-impl</artifactId>
<scope>compile</scope>
</dependency>
diff --git a/packaging/hudi-metaserver-server-bundle/pom.xml
b/packaging/hudi-metaserver-server-bundle/pom.xml
index d89a6bf3efa2..6e9fc7916f34 100644
--- a/packaging/hudi-metaserver-server-bundle/pom.xml
+++ b/packaging/hudi-metaserver-server-bundle/pom.xml
@@ -67,7 +67,7 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
+ <artifactId>log4j-slf4j2-impl</artifactId>
<version>${log4j2.version}</version>
<scope>compile</scope>
</dependency>
@@ -106,7 +106,7 @@
<include>org.apache.logging.log4j:log4j-api</include>
<include>org.apache.logging.log4j:log4j-core</include>
<include>org.apache.logging.log4j:log4j-1.2-api</include>
-
<include>org.apache.logging.log4j:log4j-slf4j-impl</include>
+
<include>org.apache.logging.log4j:log4j-slf4j2-impl</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:jul-to-slf4j</include>
<include>org.mybatis:mybatis</include>
diff --git a/pom.xml b/pom.xml
index c7e2dcfec96d..41679bc13055 100644
--- a/pom.xml
+++ b/pom.xml
@@ -123,7 +123,7 @@
<junit.platform.version>1.14.1</junit.platform.version>
<mockito.jupiter.version>5.21.0</mockito.jupiter.version>
<log4j2.version>2.25.4</log4j2.version>
- <slf4j.version>1.7.36</slf4j.version>
+ <slf4j.version>2.0.7</slf4j.version>
<joda.version>2.9.9</joda.version>
<hadoop.version>2.10.2</hadoop.version>
<hive.groupid>org.apache.hive</hive.groupid>
@@ -840,7 +840,7 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
+ <artifactId>log4j-slf4j2-impl</artifactId>
<version>${log4j2.version}</version>
<scope>provided</scope>
</dependency>
@@ -1051,6 +1051,11 @@
<groupId>org.slf4j</groupId>
<artifactId>*</artifactId>
</exclusion>
+ <!-- Spark 3.3 pulls in the slf4j 1.x binding, which collides with
log4j-slf4j2-impl -->
+ <exclusion>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ </exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
@@ -1099,6 +1104,11 @@
<groupId>org.slf4j</groupId>
<artifactId>*</artifactId>
</exclusion>
+ <!-- Spark 3.3 pulls in the slf4j 1.x binding, which collides with
log4j-slf4j2-impl -->
+ <exclusion>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ </exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
@@ -1492,6 +1502,11 @@
<groupId>org.pentaho</groupId>
<artifactId>*</artifactId>
</exclusion>
+ <!-- Hive pulls in the slf4j 1.x binding, which collides with
log4j-slf4j2-impl -->
+ <exclusion>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
@@ -1512,6 +1527,11 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
+ <!-- Hive pulls in the slf4j 1.x binding, which collides with
log4j-slf4j2-impl -->
+ <exclusion>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ </exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
@@ -1528,6 +1548,11 @@
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
+ <!-- Hive pulls in the slf4j 1.x binding, which collides with
log4j-slf4j2-impl -->
+ <exclusion>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
@@ -1556,6 +1581,11 @@
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
+ <!-- Hive pulls in the slf4j 1.x binding, which collides with
log4j-slf4j2-impl -->
+ <exclusion>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ </exclusion>
<exclusion>
<groupId>org.apache.hbase</groupId>
<artifactId>*</artifactId>