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,
- is it possible to retrieve everything that Jetty registered during classpath scanning, and
- can we disable Jetty's classpath scanning and instead manually specify classes?
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()
});
Webapps (either
*.warfiles, 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.xmlduring the startup of theWebAppContext.See Enable Jandex index for Jetty for how to do generate that
WEB-INF/quickstart-web.xmlin an embedded mode application.If you don't need a war file, use a
ServletContextHandlerand just add all of the servlets / filters / listeners your application needs against thatServletContextHandler. There will be no auto discovery performed.