This is an automated email from the ASF dual-hosted git repository.
gerlowskija pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 48a7b415e35 SOLR-17883: Add <install>/lib to tool classpath (#3566)
48a7b415e35 is described below
commit 48a7b415e35a0331da46c2e8d03c3857e1fe23bb
Author: Jason Gerlowski <[email protected]>
AuthorDate: Wed Oct 1 12:50:42 2025 -0400
SOLR-17883: Add <install>/lib to tool classpath (#3566)
Prior to this commit, the classpath for tools like "bin/solr zk"
consisted only of directories like `server/lib/ext` that already serve a
particular purpose (e.g. webapp libs, Jetty libs, etc). There was no
great place to put plugin jars needed by "bin/solr".
This commit addresses this by adding `<install>/lib` to the tool
classpath. This directory is already on Solr's classpath, so jars put
here are accessible by SolrCLI tools, as well as the Solr server proper.
---
solr/CHANGES.txt | 2 ++
solr/bin/solr | 2 +-
solr/bin/solr.cmd | 8 +++---
.../modules/configuration-guide/pages/libs.adoc | 31 +++++++++-------------
4 files changed, 19 insertions(+), 24 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 88d63a52e02..6f55a47f1cf 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -270,6 +270,8 @@ Improvements
* SOLR-17921: SolrJ CloudSolrClient configured with a Solr URL (not ZK) now
refreshes liveNodes in the background.
This will reduce spikes in request latency when the cached liveNodes have
expired. (Houston Putman, David Smiley)
+* SOLR-17883: SolrCLI tools such as "bin/solr zk" can now access jars located
in `<install_dir>/lib`.
+
Optimizations
---------------------
(No changes)
diff --git a/solr/bin/solr b/solr/bin/solr
index ec54e027a26..5c9e1a3f438 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -499,7 +499,7 @@ function run_tool() {
"$JAVA" $SOLR_SSL_OPTS $AUTHC_OPTS ${SOLR_ZK_CREDS_AND_ACLS:-}
${SOLR_TOOL_OPTS:-} -Dsolr.install.dir="$SOLR_TIP" \
-Dlog4j.configurationFile="$DEFAULT_SERVER_DIR/resources/log4j2-console.xml"
-Dsolr.pid.dir="$SOLR_PID_DIR" \
-Djava.io.tmpdir="$(cd "${TMPDIR:-${TEMP:-${TMP:-/tmp}}}"; pwd -P)" \
- -classpath
"$DEFAULT_SERVER_DIR/solr-webapp/webapp/WEB-INF/lib/*:$DEFAULT_SERVER_DIR/lib/ext/*:$DEFAULT_SERVER_DIR/lib/*"
\
+ -classpath
"$SOLR_TIP/lib/*:$DEFAULT_SERVER_DIR/solr-webapp/webapp/WEB-INF/lib/*:$DEFAULT_SERVER_DIR/lib/ext/*:$DEFAULT_SERVER_DIR/lib/*"
\
org.apache.solr.cli.SolrCLI "$@"
return $?
diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd
index c679da7f794..70a05e72e4a 100755
--- a/solr/bin/solr.cmd
+++ b/solr/bin/solr.cmd
@@ -257,7 +257,7 @@ IF "%1"=="auth" goto set_script_cmd
REM Handle all other commands by simply running SolrCLI
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS%
%SOLR_TOOL_OPTS% -Dsolr.install.dir="%SOLR_TIP%" ^
-Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml"
^
- -classpath
"%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*"
^
+ -classpath
"%SOLR_TIP%\lib\*;%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*"
^
org.apache.solr.cli.SolrCLI %*
if errorlevel 1 (
exit /b 1
@@ -746,7 +746,7 @@ IF NOT "%EXAMPLE%"=="" (
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS%
%SOLR_TOOL_OPTS% -Dsolr.install.dir="%SOLR_TIP%" ^
-Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml"
^
-Dsolr.install.symDir="%SOLR_TIP%" ^
- -classpath
"%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*"
^
+ -classpath
"%SOLR_TIP%\lib\*;%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*"
^
org.apache.solr.cli.SolrCLI run_example --script "%SDIR%\solr.cmd" -e
%EXAMPLE% --server-dir "%SOLR_SERVER_DIR%" --jvm-opts "%SOLR_ADDL_ARGS%" ^
--url-scheme !SOLR_URL_SCHEME! !PASS_TO_RUN_EXAMPLE!
@@ -1140,7 +1140,7 @@ IF "%FG%"=="1" (
REM now wait to see Solr come online ...
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS%
%SOLR_TOOL_OPTS% -Dsolr.install.dir="%SOLR_TIP%" ^
-Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml"
^
- -classpath
"%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*"
^
+ -classpath
"%SOLR_TIP%\lib\*;%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*"
^
org.apache.solr.cli.SolrCLI status --max-wait-secs !SOLR_START_WAIT!
IF NOT "!ERRORLEVEL!"=="0" (
set "SCRIPT_ERROR=Solr did not start or was not reachable. Check the
logs for errors."
@@ -1188,7 +1188,7 @@ IF NOT EXIST "%SOLR_HOME%\" (
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS%
%SOLR_TOOL_OPTS% -Dsolr.install.dir="%SOLR_TIP%" ^
-Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml"
^
- -classpath
"%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*"
^
+ -classpath
"%SOLR_TIP%\lib\*;%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*"
^
org.apache.solr.cli.SolrCLI auth %AUTH_PARAMS% --solr-include-file
"%SOLR_INCLUDE%" --auth-conf-dir "%SOLR_HOME%"
goto done
diff --git a/solr/solr-ref-guide/modules/configuration-guide/pages/libs.adoc
b/solr/solr-ref-guide/modules/configuration-guide/pages/libs.adoc
index 2ad86d6355b..9ed94fbc84e 100644
--- a/solr/solr-ref-guide/modules/configuration-guide/pages/libs.adoc
+++ b/solr/solr-ref-guide/modules/configuration-guide/pages/libs.adoc
@@ -1,4 +1,4 @@
-= Lib Directories and Directives
+= Lib Directories
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
@@ -26,24 +26,17 @@ If there is overlap or inter-dependencies between
libraries, then pay attention
== Lib Directories
-There are several special places you can place Solr plugin `.jar` files:
+There are several special places you can place Solr plugin `.jar` files,
described in the table below:
-* `<solr_home>/lib/`: The `.jar` files placed here are available to all Solr
cores running on the node, and to node level plugins referenced in `solr.xml`
-- so basically everything.
-This directory is not present by default so you will need to create it.
-See xref:deployment-guide:taking-solr-to-production.adoc[].
-* `<core_instance>/lib/`: In a user-managed cluster or a single-node
installation, you may want to add plugins just for a specific Solr core.
-Create this adjacent to the `<core_instance>/conf/` directory; it's not
present by default.
+[width="100%",options="header",]
+|===
+|Location |Visible To |Purpose |Additional Notes
+|`<solr_install>/lib/` | Everything (Node-level plugins, Core-level plugins,
`bin/solr` tools) |Any plugins that administrators want to make available to
all of Solrand its tooling, esp. when building a custom Solr package or
Dockerfile. |N/A
+|`<solr_home/lib/` | Node-level plugins, Core-level plugins |Useful when
plugins should be made available to all of Solr, but cannot be put in
`<solr_install>/lib/` for whatever reason (e.g. Solr installed on read-only
file system) | Directory not present by default and must be created by
administrators. See xref:deployment-guide:taking-solr-to-production.adoc[].
+|`<core_instance>/lib/` |Core-level plugins (for a specific core)
|User-managed clusters or single-node installations that want to make a plugin
visible to a specific Solr core, but not others. |Directory is not created by
default, and must be created by administrators adjacent to
`<core_instance>/conf/`
+|`<solr_install>/server/solr-webapp/webapp/WEB-INF/lib/` |Everything
(Node-level plugins, Core-level plugins, `bin/solr` tools) |Intended for Solr's
own jars and dependencies |Should not be used for plugins, except in the case
of a few rare plugin typs whose documentation explicitly calls out the need for
placement here.
+|`<solr_install>/server/lib/ext` |Everything (Node-level plugins, Core-level
plugins, `bin/solr` tools) |Intended to contain Jetty jars and other things
needed by the Jetty servlet classpath. Not typically used for plugins |N/A
+|===
-* `<solr_install>/lib/`: The `.jar` files placed here are available to all
Solr cores running on the node, and to node level plugins referenced in
`solr.xml` -- so basically everything.
-Contrary to `<solr_home>/lib/`, this directory is always located in the
install dir, so it can be used e.g. for custom
-Dockerfile to place custom plugin jars.
-
-* `<solr_install>/server/solr-webapp/webapp/WEB-INF/lib/`: The `.jar` files
for Solr itself and it's dependencies live here.
-Certain plugins or add-ons to plugins require placement here, and they will
have explicit documentation for this need.
-
-* `<solr_install>/server/lib/ext`: The `.jar` files used for the Solr server
as well as Solr Core/SolrJ.
-
-Solr incorporates Jetty for providing HTTP server functionality.
-Jetty has some directories that contain `.jar` files for itself and its own
plugins / modules or JVM level plugins (e.g., loggers).
-Solr plugins won't work in these locations.
+Note that while it's possible to place custom code in
`<solr_install>/server/solr-webapp/webapp/WEB-INF/lib/` and
`<solr_install>/server/lib/ext/`, doing so is discouraged as these directories
are intended for holding Solr and Jetty code, respectively.