I'm trying to set up a default descriptor in a shared place, and
a specific descriptor in WEB-INF/web.xml
I have two contexts, and I use the method below to define them.
I get the following error for the 2nd context (seems like the
first one doesn't error):
2017-07-13 11:59:02.116:WARN:oejw.WebAppContext:main: Failed
startup of context
o.e.j.w.WebAppContext@37cd92d6{/,file:///E:/Workspace/git/Debug/webapps/context2/,UNAVAILABLE,localhost2.com}
java.lang.IllegalArgumentException: name
at
sun.misc.URLClassPath$Loader.findResource(URLClassPath.java:693)
at sun.misc.URLClassPath.findResource(URLClassPath.java:215)
at java.net.URLClassLoader$2.run(URLClassLoader.java:569)
at java.net.URLClassLoader$2.run(URLClassLoader.java:567)
at java.security.AccessController.doPrivileged(Native Method)
at
java.net.URLClassLoader.findResource(URLClassLoader.java:566)
at java.lang.ClassLoader.getResource(ClassLoader.java:1096)
at
org.eclipse.jetty.util.resource.Resource.newSystemResource(Resource.java:242)
at
org.eclipse.jetty.webapp.WebXmlConfiguration.preConfigure(WebXmlConfiguration.java:50)
at
org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:506)
at
org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:544)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at
org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
at
org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113)
at
org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at
org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
at org.eclipse.jetty.server.Server.start(Server.java:452)
at
org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105)
at
org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.server.Server.doStart(Server.java:419)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
/**
*
* @param resourceBase the path to the web root
* @param contextPath the virtual path for the context, e.g. "/"
* @return
* @throws Exception
*/
public static WebAppContext createWebAppContext(String resourceBase, String contextPath) throws Exception {
File file = new File(resourceBase);
resourceBase = file.getCanonicalPath();
if (contextPath == null || contextPath.isEmpty())
contextPath = "/";
WebAppContext webapp = new WebAppContext();
webapp.setContextPath(contextPath);
webapp.setResourceBase(resourceBase);
webapp.setConfigurationClasses(webappDefaultConfigurationClasses);
// Set default descriptor for all contexts
webapp.setDefaultsDescriptor(DebugLucee.class.getResource("/resource/web.xml").getPath());
// Set app-specific descriptor at {webroot}/WEB-INF/web.xml
webapp.setDescriptor(resourceBase + "/WEB-INF/web.xml");
return webapp;
}
public static final String[] webappDefaultConfigurationClasses = new String[]{
"org.eclipse.jetty.webapp.WebInfConfiguration"
,"org.eclipse.jetty.webapp.WebXmlConfiguration"
,"org.eclipse.jetty.webapp.MetaInfConfiguration"
,"org.eclipse.jetty.webapp.FragmentConfiguration"
,"org.eclipse.jetty.annotations.AnnotationConfiguration"
,"org.eclipse.jetty.webapp.JettyWebXmlConfiguration"
};
Is it possible to achieve that? If so, how? Thanks!