jetty-ee8-maven-plugin
attempts to load default configurations twice, precluding use of custom class loader in WebAppContext
#11762
Labels
Bug
For general bugs on Jetty side
Jetty version(s)
12.0.8
Jetty Environment
EE8
Java version/vendor
(use: java -version)
OS type/version
Ubuntu 22.04.4 LTS x86_64
Description
Suppose
jetty-ee8-maven-plugin
is used with an instance ofWebAppClassLoader
set as theWebAppContext
's class loader (rather than the default Maven realm class loader), as in https://github.com/jenkinsci/maven-hpi-plugin/blob/399e311e79235712e0eed9ff99ed7a2daac7fe4e/src/main/java/org/jenkinsci/maven/plugins/hpi/RunMojo.java#L795. Then whenServerSupport.configureDefaultConfigurationClasses(server)
is called fromJettyEmbedder#configure
, all is well, since the context class loader is not theWebAppClassLoader
and has access to server classes from which to load the configurations. But when we later get toContextHandler.CoreContextHandler#doStart
, the thread's context class loader is set to theWebAppContext
's class loader, and when we get toWebAppContext#preConfigure
and then toWebAppContext#loadConfigurations
we will now again callWebAppContext#newConfigurations
, which will now fail because theWebAppClassLoader
does not have access to the requisite server classes from which to load the configuration.I was able to work around the problem in https://github.com/jenkinsci/maven-hpi-plugin/blob/399e311e79235712e0eed9ff99ed7a2daac7fe4e/src/main/java/org/jenkinsci/maven/plugins/hpi/RunMojo.java#L617-L623, but this seems like a bug in
jetty-ee8-maven-plugin
. I suggest reusing the default configuration and not trying to load it a second time.This bug was introduced after Jetty 10.0.20, since we are not experiencing it on that release but are experiencing it on 12.0.8.
How to reproduce?
Remove the workaround described above, build
maven-hpi-plugin
at theprototype
branch I linked to above, and then executemvn hpi:run
from a Jenkins plugin using the abovementioned build.The text was updated successfully, but these errors were encountered: