From 1212ebfa2fed0a148d289c395a50eb383c8869f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Manciot?= Date: Thu, 30 Jul 2026 14:59:13 +0200 Subject: [PATCH] fix(build): add explicit log4j-api to es6 client dependencies (Closed Issue #168) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The global excludeSlf4jAndLog4j rule strips every org.apache.logging.log4j artifact from the dependency closure, but ES6's RestHighLevelClient hard-references org.apache.logging.log4j.LogManager. The published softclient4es6-rest-client — and therefore the plain es6 cli 0.20.1 — crashed on first use with NoClassDefFoundError: org/apache/logging/log4j/LogManager. Mirror es7's explicit log4j-api re-add in elastic4sDependencies(6), pinned to Versions.log4j (2.17.1), which matches the log4j ES 6.8.23 bundles. Only the API surface is needed client-side; log4j-api's SimpleLogger fallback is fine for the cli. Also corrects the es7 comment that claimed ES6 RHLC needs no log4j. Verified: es6cli assembly now contains org/apache/logging/log4j/LogManager.class and SHOW TABLES + SELECT succeed against a live docker ES 6.8.23. Co-Authored-By: Claude Fable 5 --- project/SoftClient4es.scala | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/project/SoftClient4es.scala b/project/SoftClient4es.scala index 3346e8a4..725b3a87 100644 --- a/project/SoftClient4es.scala +++ b/project/SoftClient4es.scala @@ -68,7 +68,18 @@ trait SoftClient4es { case 6 => Seq( "com.sksamuel.elastic4s" %% "elastic4s-core" % Versions.elastic64s exclude ("org.elasticsearch", "elasticsearch") exclude ("org.slf4j", "slf4j-api"), - "com.sksamuel.elastic4s" %% "elastic4s-http" % Versions.elastic64s exclude ("org.elasticsearch", "elasticsearch") + "com.sksamuel.elastic4s" %% "elastic4s-http" % Versions.elastic64s exclude ("org.elasticsearch", "elasticsearch"), + // Same story as ES7 below (issue #168): ES6's elastic4s-http pulls + // elasticsearch-rest-high-level-client 6.8.x, whose hard-references + // org.apache.logging.log4j.LogManager (log4j-api), while excludeSlf4jAndLog4j strips + // every org.apache.logging.log4j artifact from the closure. Without this explicit + // re-add the published softclient4es6-rest-client — and therefore the plain es6 REPL — + // crashes on the first ES call with + // NoClassDefFoundError: org/apache/logging/log4j/LogManager. + // Versions.log4j (2.17.1) matches the log4j the ES 6.8.23 server bundles; only the + // log4j-api surface is needed client-side (no provider required — log4j-api falls + // back to its no-op/SimpleLogger provider, which is fine for the cli). + "org.apache.logging.log4j" % "log4j-api" % Versions.log4j ) case 7 => Seq( @@ -80,7 +91,8 @@ trait SoftClient4es { // the es7 JDBC driver and the arrow es7 sidecar — crash on the first ES call with // NoClassDefFoundError: org/apache/logging/log4j/LogManager. // Versions.log4j (2.17.1) matches the log4j-core ES 7.17 bundles, keeping the pair - // aligned. (ES6 RHLC needs no log4j; ES8/9 use the new Java client.) + // aligned. (ES6's RHLC has the same LogManager hard reference — handled above, see + // issue #168; ES8/9 use the new Java client.) "org.apache.logging.log4j" % "log4j-api" % Versions.log4j ) case 8 =>