use of org.eclipse.jetty.webapp.JettyWebXmlConfiguration in project shiro by apache.
the class AbstractContainerIT method startContainer.
@BeforeClass
public static void startContainer() throws Exception {
EmbeddedJettyConfiguration config = EmbeddedJettyConfiguration.builder().withWebapp(getWarDir()).build();
jetty = new EmbeddedJetty(config) {
/**
* Overriding with contents of this pull request, to make fragment scanning work.
* https://github.com/mjeanroy/junit-servers/pull/3
*/
protected WebAppContext createdWebAppContext() throws Exception {
final String path = configuration.getPath();
final String webapp = configuration.getWebapp();
final String classpath = configuration.getClasspath();
WebAppContext ctx = new WebAppContext();
ctx.setClassLoader(Thread.currentThread().getContextClassLoader());
ctx.setContextPath(path);
// Useful for WebXmlConfiguration
ctx.setBaseResource(newResource(webapp));
ctx.setConfigurations(new Configuration[] { new WebInfConfiguration(), new WebXmlConfiguration(), new AnnotationConfiguration(), new JettyWebXmlConfiguration(), new MetaInfConfiguration(), new FragmentConfiguration() });
if (isNotBlank(classpath)) {
// Fix to scan Spring WebApplicationInitializer
// This will add compiled classes to jetty classpath
// See: http://stackoverflow.com/questions/13222071/spring-3-1-webapplicationinitializer-embedded-jetty-8-annotationconfiguration
// And more precisely: http://stackoverflow.com/a/18449506/1215828
File classes = new File(classpath);
FileResource containerResources = new FileResource(classes.toURI());
ctx.getMetaData().addContainerResource(containerResources);
}
Server server = getDelegate();
ctx.setParentLoaderPriority(true);
ctx.setWar(webapp);
ctx.setServer(server);
// Add server context
server.setHandler(ctx);
return ctx;
}
};
jetty.start();
assertTrue(jetty.isStarted());
}
use of org.eclipse.jetty.webapp.JettyWebXmlConfiguration in project Openfire by igniterealtime.
the class AdminConsolePlugin method createWebAppContext.
private void createWebAppContext() {
contexts = new ContextHandlerCollection();
WebAppContext context = new WebAppContext(contexts, pluginDir.getAbsoluteFile() + File.separator + "webapp", "/");
// Ensure the JSP engine is initialized correctly (in order to be able to cope with Tomcat/Jasper precompiled JSPs).
final List<ContainerInitializer> initializers = new ArrayList<>();
initializers.add(new ContainerInitializer(new JasperInitializer(), null));
context.setAttribute("org.eclipse.jetty.containerInitializers", initializers);
context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
context.setConfigurations(new Configuration[] { new AnnotationConfiguration(), new WebInfConfiguration(), new WebXmlConfiguration(), new MetaInfConfiguration(), new FragmentConfiguration(), new EnvConfiguration(), new PlusConfiguration(), new JettyWebXmlConfiguration() });
final URL classes = getClass().getProtectionDomain().getCodeSource().getLocation();
context.getMetaData().setWebInfClassesDirs(Collections.singletonList(Resource.newResource(classes)));
// The index.html includes a redirect to the index.jsp and doesn't bypass
// the context security when in development mode
context.setWelcomeFiles(new String[] { "index.html" });
}
Aggregations