I am using jetty-server:9.2.11 and I want to have a webapps directory for war deployment in my embedded jetty application like that we have when use standalone jetty server. I read some documentation and found "Like Jetty XML" programmatic configuration like below
// Path to as-built jetty-distribution directory
String jettyHomeBuild = "../../jetty-distribution/target/distribution";
// Find jetty home and base directories
String homePath = System.getProperty("jetty.home", jettyHomeBuild);
File homeDir = new File(homePath);
if (!homeDir.exists())
{
throw new FileNotFoundException(homeDir.getAbsolutePath());
}
String basePath = System.getProperty("jetty.base", homeDir + "/demo-base");
File baseDir = new File(basePath);
if(!baseDir.exists())
{
throw new FileNotFoundException(baseDir.getAbsolutePath());
}
// Configure jetty.home and jetty.base system properties
String jetty_home = homeDir.getAbsolutePath();
String jetty_base = baseDir.getAbsolutePath();
System.setProperty("jetty.home", jetty_home);
System.setProperty("jetty.base", jetty_base);
// === jetty-deploy.xml ===
DeploymentManager deployer = new DeploymentManager();
deployer.setContexts(contexts);
deployer.setContextAttribute(
"org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
".*/servlet-api-[^/]*\\.jar$");
WebAppProvider webapp_provider = new WebAppProvider();
webapp_provider.setMonitoredDirName(jetty_base + "/webapps");
webapp_provider.setDefaultsDescriptor(jetty_home + "/etc/webdefault.xml");
webapp_provider.setScanInterval(1);
webapp_provider.setExtractWars(true);
webapp_provider.setConfigurationManager(new PropertiesConfigurationManager());
deployer.addAppProvider(webapp_provider);
server.addBean(deployer);
But here uses "jetty-distribution" but I only have jetty related jar files in my lib directory that get copied as maven dependencies. I'm kind of stuck here to do my configuration to have "jetty.home" for my embedded jetty application because I'm not using any standard jetty distribution.I only have separate jars.