How to make Jetty load webdefault.xml when it runs in OSGi?
I'm running a Jetty 8.1.12 server within an OSGi container thanks to jetty-osgi-boot as explained in Jetty 8 and Jetty 9 documentation
I want to configure the default webapp descriptor ( etc/webdefault.xml
). When I define jetty.home
, jetty picks up etc/jetty.xml
but it does not load etc/webdefault.xml
I do not want to rely on a configuration bundle (through the jetty.home.bundle
system property) because I want the config easily modifiable.
I do not want to rely on the Jetty-defaultWebXmlFilePath
MANIFEST header for the same reason, plus it would tie my webapp to jetty.
The jetty-osgi-boot bundle contains a jetty-deployer.xml
configuration file with this commented-out chunk :
<!-- Providers of OSGi Apps -->
<Call name="addAppProvider">
<Arg>
<New class="org.eclipse.jetty.osgi.boot.OSGiAppProvider">
<Set name="defaultsDescriptor"><Property name="jetty.home" default="."/>/etc/webdefault.xml</Set>
...
which does not work because the OSGiAppProvider
class does not exist anymore.
Is there any other way to configure the webdefaults.xml file location ?
Short answer : I could not have jetty 8.1.12 to load webdefaults.xml under OSGi.
After many hours of googling, source-reading and debugging, I came to these conclusions :
The Jetty-defaultWebXmlFilePath
MANIFEST header did not work as expected. It could not resolve a bundle entry path, only a absolute file system path. An absolute FS path was not a realistic option.
Much of the configuration is hardcoded in ServerInstanceWrapper
and the likes of BundleWebAppProvider
so we cannot configure defaults descriptor location. This location ends up to the default, which is, IIRC, org/eclipse/jetty/webapp/webdefault.xml
.
I resorted to patching jetty-osgi so that it can read some configuration and apply it to BundleWebAppProvider
. FWIW this hack is available on github