fix(build): es6 cli crashes on first use — add explicit log4j-api (#168) - #173
Draft
fupelaqu wants to merge 1 commit into
Draft
fix(build): es6 cli crashes on first use — add explicit log4j-api (#168)#173fupelaqu wants to merge 1 commit into
fupelaqu wants to merge 1 commit into
Conversation
… Issue #168) The global excludeSlf4jAndLog4j rule strips every org.apache.logging.log4j artifact from the dependency closure, but ES6's RestHighLevelClient <clinit> 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 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #168.
Root cause
The global
excludeSlf4jAndLog4jrules inproject/SoftClient4es.scalastrip everyorg.apache.logging.log4jartifact from the published dependency closure, while ES6'sRestHighLevelClient<clinit>hard-referencesorg.apache.logging.log4j.LogManager(log4j-api). As a result the publishedsoftclient4es6-rest-client— and therefore the plain es6 cli 0.20.1 — crashed on first use with:es7 already carried an explicit
log4j-apire-add for the exact same reason; es6 did not (the es7 comment even claimed "ES6 RHLC needs no log4j" — disproved by REPL.4's bundle E2E smoke on ES 6.8.23).Fix
Mirror es7's explicit dependency in
elastic4sDependencies(6):"org.apache.logging.log4j" % "log4j-api" % Versions.log4j(2.17.1 — 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)Verification
sbt es6cli/assembly— assembly jar now containsorg/apache/logging/log4j/LogManager.classelasticsearch:6.8.23(single node, green):java -jar softclient4es6-cli-0.20.1-assembly.jar -p 9268 -c "SHOW TABLES"and aSELECT name, age FROM peopleafter indexing a doc — both succeed, noNoClassDefFoundError(log4j-api falls back to SimpleLogger with a benign StatusLogger notice)sbt "+ es6rest/compile" "+ es6jest/compile" scalafmtCheck— all green (Scala 2.12 + 2.13)Notes
🤖 Generated with Claude Code