Malini Kennady
Malini Kennady

Reputation: 373

Custom folder for dependency JAR in Jetty

I am using Jetty 9.2. I have a dependency JAR which I am currently placing in "lib/ext/" folder thus it loads automatically. I have also tried using "--lib=%EXT_JAR PATH%" in "start.bat" of Jetty. This loads the JAR on startup. Is it possible to keep the JAR in a custom folder and make it to load automatically on start classloader without specifying in "start.bat" file?

Thanks in advance.

Upvotes: 0

Views: 360

Answers (1)

Joakim Erdfelt
Joakim Erdfelt

Reputation: 49462

Add the ext module to your ${jetty.base} configuration and then place the jars in ${jetty.base}/lib/ext. (Note: these jars are only available to the server classloader, not the webapps)

Command line example:

# Do all of the commands from your jetty-base
$ cd /path/to/mybase

# Add 'ext' module (to either start.ini or start.d/ext.ini)
$ java -jar /path/to/jetty-dist/start.jar --add-to-start=ext

# Copy jars into place
$ cp /home/malini/code/project/target/special.jar /path/to/mybase/lib/ext/

# Verify that lib is present in server classpath/classloader
$ java -jar /path/to/jetty-dist/start.jar --list-config

# Run jetty
$ java -jar /path/to/jetty-dist/start.jar

Upvotes: 1

Related Questions