Reputation: 1655
https://eclipse.dev/jetty/documentation/jetty-12/operations-guide/index.html#og-quickstart
Is it possible to use Jetty Quickstart with embedded Jetty. We do not have a web.xml
.
Our goal is to decrease startup times by eliminating Jetty's classpath scanning. If we cannot get Quickstart to work,
final WebAppContext context = new WebAppContext();
final ResourceFactory resourceFactory = ResourceFactory.of(context);
context.setDisplayName("PORTAL");
context.setContextPath("/");
final Resource webRootResource = findWebRoot(resourceFactory);
context.setBaseResource(webRootResource);
context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*");
context.setConfigurationDiscovered(true);
context.setParentLoaderPriority(true);
context.setConfigurations(new Configuration[] {
new AnnotationConfiguration(),
new WebAppConfiguration(),
new WebInfConfiguration(),
new WebXmlConfiguration(),
new MetaInfConfiguration(),
new FragmentConfiguration(),
new EnvConfiguration(),
new PlusConfiguration(),
new JettyWebXmlConfiguration(),
new JakartaWebSocketConfiguration()
});
Upvotes: 0
Views: 246
Reputation: 49515
Webapps (either *.war
files, or exploded directories) are the only thing in Jetty that have the auto-discovery / bytecode scanning features.
The quickstart mechanism is for webapps.
It works by having the webapp initialization look for a WEB-INF/quickstart-web.xml
during the startup of the WebAppContext
.
See Enable Jandex index for Jetty for how to do generate that WEB-INF/quickstart-web.xml
in an embedded mode application.
If you don't need a war file, use a ServletContextHandler
and just add all of the servlets / filters / listeners your application needs against that ServletContextHandler
. There will be no auto discovery performed.
Upvotes: 0