Skip to content

fix(build): es6 cli crashes on first use — add explicit log4j-api (#168) - #173

Draft
fupelaqu wants to merge 1 commit into
mainfrom
fix/168-es6-log4j-api
Draft

fix(build): es6 cli crashes on first use — add explicit log4j-api (#168)#173
fupelaqu wants to merge 1 commit into
mainfrom
fix/168-es6-log4j-api

Conversation

@fupelaqu

Copy link
Copy Markdown
Contributor

Closes #168.

Root cause

The global excludeSlf4jAndLog4j rules in project/SoftClient4es.scala strip every org.apache.logging.log4j artifact from the published dependency closure, while ES6's RestHighLevelClient <clinit> hard-references org.apache.logging.log4j.LogManager (log4j-api). As a result 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

es7 already carried an explicit log4j-api re-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):

Verification

  • sbt es6cli/assembly — assembly jar now contains org/apache/logging/log4j/LogManager.class
  • Live smoke against docker elasticsearch:6.8.23 (single node, green): java -jar softclient4es6-cli-0.20.1-assembly.jar -p 9268 -c "SHOW TABLES" and a SELECT name, age FROM people after indexing a doc — both succeed, no NoClassDefFoundError (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

… 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ES6 client crashes with NoClassDefFoundError: org/apache/logging/log4j/LogManager (log4j fully excluded from the es6 closure)

1 participant