Java Code Examples for org.eclipse.jetty.webapp.WebAppContext#setInitParameter()

The following examples show how to use org.eclipse.jetty.webapp.WebAppContext#setInitParameter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebServer.java    From haxademic with MIT License 6 votes vote down vote up
protected void configServer() {
       // init static web server
       WebAppContext webAppContext = new WebAppContext(wwwPath, "/");
       
       // turn off file locking! 
       // without this, we were blocked from dynamically replace static files in the web server directory at runtime
       webAppContext.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
       
       // set custom & static handlers
       HandlerList handlers = new HandlerList();
       handlers.setHandlers(new Handler[] { 
   		this.handler, 
   		webAppContext 			// Jetty's built-in static asset web server. this catches any request not handled by the custom handler
       });
       server.setHandler(handlers);
}
 
Example 2
Source File: GatewayServer.java    From knox with Apache License 2.0 6 votes vote down vote up
private WebAppContext createWebAppContext( Topology topology, File warFile, String warPath ) {
  String topoName = topology.getName();
  WebAppContext context = new WebAppContext();
  String contextPath;
  contextPath = "/" + Urls.trimLeadingAndTrailingSlashJoin( config.getGatewayPath(), topoName, warPath );
  context.setContextPath( contextPath );
  SessionCookieConfig sessionCookieConfig = context.getServletContext().getSessionCookieConfig();
  sessionCookieConfig.setName(KNOXSESSIONCOOKIENAME);
  context.setWar( warFile.getAbsolutePath() );
  context.setAttribute( GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE, topoName );
  context.setAttribute( "org.apache.knox.gateway.frontend.uri", getFrontendUri( context, config ) );
  context.setAttribute( GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE, config );
  // Add support for JSPs.
  context.setAttribute(
      "org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
      ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$" );
  context.setTempDirectory( FileUtils.getFile( warFile, "META-INF", "temp" ) );
  context.setErrorHandler( createErrorHandler() );
  context.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
  ClassLoader jspClassLoader = new URLClassLoader(new URL[0], this.getClass().getClassLoader());
  context.setClassLoader(jspClassLoader);
  return context;
}
 
Example 3
Source File: ZeppelinServer.java    From zeppelin with Apache License 2.0 6 votes vote down vote up
private static void setupRestApiContextHandler(WebAppContext webapp, ZeppelinConfiguration conf) {
  final ServletHolder servletHolder =
      new ServletHolder(new org.glassfish.jersey.servlet.ServletContainer());

  servletHolder.setInitParameter("javax.ws.rs.Application", ZeppelinServer.class.getName());
  servletHolder.setName("rest");
  servletHolder.setForcedPath("rest");
  webapp.setSessionHandler(new SessionHandler());
  webapp.addServlet(servletHolder, "/api/*");

  String shiroIniPath = conf.getShiroPath();
  if (!StringUtils.isBlank(shiroIniPath)) {
    webapp.setInitParameter("shiroConfigLocations", new File(shiroIniPath).toURI().toString());
    webapp
        .addFilter(ShiroFilter.class, "/api/*", EnumSet.allOf(DispatcherType.class))
        .setInitParameter("staticSecurityManagerEnabled", "true");
    webapp.addEventListener(new EnvironmentLoaderListener());
  }
}
 
Example 4
Source File: WebSessionSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param cfg Configuration.
 * @param igniteInstanceName Ignite instance name.
 * @param servlet Servlet.
 * @return Servlet container web context for this test.
 */
protected WebAppContext getWebContext(@Nullable String cfg, @Nullable String igniteInstanceName,
    boolean keepBinaryFlag, HttpServlet servlet) {
    final String path = keepBinaryFlag ? "modules/core/src/test/webapp" : "modules/web/src/test/webapp2";

    WebAppContext ctx = new WebAppContext(U.resolveIgnitePath(path).getAbsolutePath(),
        "/ignitetest");

    ctx.setInitParameter("IgniteConfigurationFilePath", cfg);
    ctx.setInitParameter("IgniteWebSessionsGridName", igniteInstanceName);
    ctx.setInitParameter("IgniteWebSessionsCacheName", getCacheName());
    ctx.setInitParameter("IgniteWebSessionsMaximumRetriesOnFail", "100");
    ctx.setInitParameter("IgniteWebSessionsKeepBinary", Boolean.toString(keepBinaryFlag));

    ctx.addServlet(new ServletHolder(servlet), "/*");

    return ctx;
}
 
Example 5
Source File: JettyServer.java    From celos with Apache License 2.0 5 votes vote down vote up
private void startServer() throws Exception {
    URL url = Thread.currentThread().getContextClassLoader().getResource("WEB-INF");
    URIBuilder uriBuilder = new URIBuilder(url.toURI());
    uriBuilder.setPath(Paths.get(url.getPath()).getParent().toString());

    context = new WebAppContext(uriBuilder.toString() + "/", "/");
    context.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");

    context.setExtractWAR(false);

    server.setHandler(context);
    server.start();
}
 
Example 6
Source File: StartHelper.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @see org.projectforge.webserver.AbstractStartHelper#getWebAppContext()
 */
@Override
protected WebAppContext getWebAppContext()
{
  final WebAppContext webAppContext = new WebAppContext();
  webAppContext.setClassLoader(this.getClass().getClassLoader());
  webAppContext.setConfigurationClasses(CONFIGURATION_CLASSES);
  webAppContext.setContextPath("/ProjectForge");
  webAppContext.setWar("src/main/webapp");
  webAppContext.setDescriptor("src/main/webapp/WEB-INF/web.xml");
  webAppContext.setExtraClasspath("target/classes");
  webAppContext.setInitParameter("development", String.valueOf(startSettings.isDevelopment()));
  webAppContext.setInitParameter("stripWicketTags", String.valueOf(startSettings.isStripWicketTags()));
  return webAppContext;
}
 
Example 7
Source File: JettyServer.java    From jqm with Apache License 2.0 5 votes vote down vote up
private void loadWar(DbConn cnx)
{
    File war = new File("./webapp/jqm-ws.war");
    if (!war.exists() || !war.isFile())
    {
        return;
    }
    jqmlogger.info("Jetty will now load the web service application war");

    // Load web application.
    webAppContext = new WebAppContext(war.getPath(), "/");
    webAppContext.setDisplayName("JqmWebServices");

    // Hide server classes from the web app
    webAppContext.getServerClasspathPattern().add("com.enioka.jqm.api."); // engine and webapp can have different API implementations
                                                                          // (during tests mostly)
    webAppContext.getServerClasspathPattern().add("com.enioka.jqm.tools.");
    webAppContext.getServerClasspathPattern().add("-com.enioka.jqm.tools.JqmXmlException"); // inside XML bundle, not engine.
    webAppContext.getServerClasspathPattern().add("-com.enioka.jqm.tools.XmlJobDefExporter");

    // JQM configuration should be on the class path
    webAppContext.setExtraClasspath("conf/jqm.properties");
    webAppContext.setInitParameter("jqmnode", node.getName());
    webAppContext.setInitParameter("jqmnodeid", node.getId().toString());
    webAppContext.setInitParameter("enableWsApiAuth", GlobalParameter.getParameter(cnx, "enableWsApiAuth", "true"));

    // Set configurations (order is important: need to unpack war before reading web.xml)
    webAppContext.setConfigurations(new Configuration[] { new WebInfConfiguration(), new WebXmlConfiguration(),
            new MetaInfConfiguration(), new FragmentConfiguration(), new AnnotationConfiguration() });

    handlers.addHandler(webAppContext);
}
 
Example 8
Source File: ServerDaemon.java    From cloudstack with Apache License 2.0 5 votes vote down vote up
private Pair<SessionHandler,HandlerCollection> createHandlers() {
    final WebAppContext webApp = new WebAppContext();
    webApp.setContextPath(contextPath);
    webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");

    // GZIP handler
    final GzipHandler gzipHandler = new GzipHandler();
    gzipHandler.addIncludedMimeTypes("text/html", "text/xml", "text/css", "text/plain", "text/javascript", "application/javascript", "application/json", "application/xml");
    gzipHandler.setIncludedMethods("GET", "POST");
    gzipHandler.setCompressionLevel(9);
    gzipHandler.setHandler(webApp);

    if (Strings.isNullOrEmpty(webAppLocation)) {
        webApp.setWar(getShadedWarUrl());
    } else {
        webApp.setWar(webAppLocation);
    }

    // Request log handler
    final RequestLogHandler log = new RequestLogHandler();
    log.setRequestLog(createRequestLog());

    // Redirect root context handler_war
    MovedContextHandler rootRedirect = new MovedContextHandler();
    rootRedirect.setContextPath("/");
    rootRedirect.setNewContextURL(contextPath);
    rootRedirect.setPermanent(true);

    // Put rootRedirect at the end!
    return new Pair<>(webApp.getSessionHandler(), new HandlerCollection(log, gzipHandler, rootRedirect));
}
 
Example 9
Source File: ZeppelinServer.java    From zeppelin with Apache License 2.0 5 votes vote down vote up
private static WebAppContext setupWebAppContext(
    ContextHandlerCollection contexts, ZeppelinConfiguration conf, String warPath, String contextPath) {
  WebAppContext webApp = new WebAppContext();
  webApp.setContextPath(contextPath);
  LOG.info("warPath is: {}", warPath);
  File warFile = new File(warPath);
  if (warFile.isDirectory()) {
    // Development mode, read from FS
    // webApp.setDescriptor(warPath+"/WEB-INF/web.xml");
    webApp.setResourceBase(warFile.getPath());
    webApp.setParentLoaderPriority(true);
  } else {
    // use packaged WAR
    webApp.setWar(warFile.getAbsolutePath());
    webApp.setExtractWAR(false);
    File warTempDirectory = new File(conf.getRelativeDir(ConfVars.ZEPPELIN_WAR_TEMPDIR) + contextPath);
    warTempDirectory.mkdir();
    LOG.info("ZeppelinServer Webapp path: {}", warTempDirectory.getPath());
    webApp.setTempDirectory(warTempDirectory);
  }
  // Explicit bind to root
  webApp.addServlet(new ServletHolder(new DefaultServlet()), "/*");
  contexts.addHandler(webApp);

  webApp.addFilter(new FilterHolder(CorsFilter.class), "/*", EnumSet.allOf(DispatcherType.class));

  webApp.setInitParameter(
      "org.eclipse.jetty.servlet.Default.dirAllowed",
      Boolean.toString(conf.getBoolean(ConfVars.ZEPPELIN_SERVER_DEFAULT_DIR_ALLOWED)));
  return webApp;
}
 
Example 10
Source File: EmbeddedServer.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
protected WebAppContext getWebAppContext(String path) {
    WebAppContext application = new WebAppContext(path, "/");
    application.setClassLoader(Thread.currentThread().getContextClassLoader());
    // Disable directory listing
    application.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
    return application;
}
 
Example 11
Source File: EmbeddedServer.java    From atlas with Apache License 2.0 5 votes vote down vote up
protected WebAppContext getWebAppContext(String path) {
    WebAppContext application = new WebAppContext(path, "/");
    application.setClassLoader(Thread.currentThread().getContextClassLoader());
    // Disable directory listing
    application.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
    return application;
}
 
Example 12
Source File: WebSessionServerStart.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @param port Port.
 * @param servlet Servlet.
 * @return Started Jetty server.
 * @throws Exception In case of error.
 */
private static Server jettyServer(int port, HttpServlet servlet) throws Exception {
    Server srv = new Server(port);

    WebAppContext ctx = new WebAppContext(U.resolveIgnitePath("modules/tests/webapp").getAbsolutePath(),
        "/ignitetest");

    ctx.setInitParameter("cfgFilePath", "/examples/config/spring-cache.xml");
    ctx.setInitParameter("IgniteWebSessionsCacheName", "partitioned");

    ctx.addServlet(new ServletHolder(servlet), "/*");

    srv.setHandler(ctx);

    return srv;
}
 
Example 13
Source File: WebAppContextProvider.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
/**
 * Serve given WAR at the given pathSpec; if not yet started, it is simply remembered until start;
 * if server already running, the context for this WAR is started.
 * @return the context created and added as a handler (and possibly already started if server is
 * started, so be careful with any changes you make to it!)
 */
public WebAppContext get(ManagementContext managementContext, Map<String, Object> attributes, boolean ignoreFailures) {
    checkNotNull(managementContext, "managementContext");
    checkNotNull(attributes, "attributes");
    boolean isRoot = pathSpec.isEmpty();

    final WebAppContext context = new WebAppContext();
    // use a unique session ID to prevent interference with other web apps on same server (esp for localhost);
    // note however this is only run for the legacy launcher
    // TODO would be nice if the various karaf startups rename the session cookie property (from JSESSIONID)
    // as the default is likely to conflict with other java-based servers (esp on localhost);
    // this can be done e.g. on ServletContext.getSessionCookieConfig(), but will be needed for REST and for JS (static) bundles
    // low priority however, if you /etc/hosts a localhost-brooklyn and use that it will stop conflicting
    context.setInitParameter(SessionHandler.__SessionCookieProperty, SessionHandler.__DefaultSessionCookie + "_" + "BROOKLYN" + Identifiers.makeRandomId(6));
    context.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
    context.setAttribute(BrooklynServiceAttributes.BROOKLYN_MANAGEMENT_CONTEXT, managementContext);
    for (Map.Entry<String, Object> attributeEntry : attributes.entrySet()) {
        context.setAttribute(attributeEntry.getKey(), attributeEntry.getValue());
    }

    try {
        final CustomResourceLocator locator = new CustomResourceLocator(managementContext.getConfig(), ResourceUtils.create(this));
        final InputStream resource = locator.getResourceFromUrl(warUrl);
        final String warName = isRoot ? "ROOT" : ("embedded-" + pathSpec);
        File tmpWarFile = Os.writeToTempFile(resource, warName, ".war");
        context.setWar(tmpWarFile.getAbsolutePath());
    } catch (Exception e) {
        LOG.warn("Failed to deploy webapp " + pathSpec + " from " + warUrl
                + (ignoreFailures ? "; launching run without WAR" : " (rethrowing)")
                + ": " + Exceptions.collapseText(e));
        if (!ignoreFailures) {
            throw new IllegalStateException("Failed to deploy webapp " + pathSpec + " from " + warUrl + ": " + Exceptions.collapseText(e), e);
        }
        LOG.debug("Detail on failure to deploy webapp: " + e, e);
        context.setWar("/dev/null");
    }

    context.setContextPath("/" + pathSpec);
    context.setParentLoaderPriority(true);

    return context;
}
 
Example 14
Source File: JettyLauncher.java    From JobX with Apache License 2.0 4 votes vote down vote up
@Override
public void start(boolean devMode, int port) throws Exception {

    Server server = new Server(new QueuedThreadPool(Constants.WEB_THREADPOOL_SIZE));

    WebAppContext appContext = new WebAppContext();
    String resourceBasePath = "";
    //开发者模式
    if (devMode) {
        String artifact = MavenUtils.get(Thread.currentThread().getContextClassLoader()).getArtifactId();
        resourceBasePath = artifact + "/src/main/webapp";
    }
    appContext.setDescriptor(resourceBasePath + "WEB-INF/web.xml");
    appContext.setResourceBase(resourceBasePath);
    appContext.setExtractWAR(true);

    //init param
    appContext.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
    if (CommonUtils.isWindows()) {
        appContext.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
    }

    //for jsp support
    appContext.addBean(new JettyJspParser(appContext));
    appContext.addServlet(JettyJspServlet.class, "*.jsp");

    appContext.setContextPath("/");
    appContext.getServletContext().setExtendedListenerTypes(true);
    appContext.setParentLoaderPriority(true);
    appContext.setThrowUnavailableOnStartupException(true);
    appContext.setConfigurationDiscovered(true);
    appContext.setClassLoader(Thread.currentThread().getContextClassLoader());


    ServerConnector connector = new ServerConnector(server);
    connector.setHost("localhost");
    connector.setPort(port);

    server.setConnectors(new Connector[]{connector});
    server.setAttribute("org.eclipse.jetty.server.Request.maxFormContentSize", 1024 * 1024 * 1024);
    server.setDumpAfterStart(false);
    server.setDumpBeforeStop(false);
    server.setStopAtShutdown(true);
    server.setHandler(appContext);
    logger.info("[JobX] JettyLauncher starting...");
    server.start();
}
 
Example 15
Source File: ServerLauncher.java    From bromium with MIT License 4 votes vote down vote up
public static void main(final String[] args) {
  InetSocketAddress _inetSocketAddress = new InetSocketAddress("localhost", 8080);
  final Server server = new Server(_inetSocketAddress);
  WebAppContext _webAppContext = new WebAppContext();
  final Procedure1<WebAppContext> _function = (WebAppContext it) -> {
    it.setResourceBase("WebRoot");
    it.setWelcomeFiles(new String[] { "index.html" });
    it.setContextPath("/");
    AnnotationConfiguration _annotationConfiguration = new AnnotationConfiguration();
    WebXmlConfiguration _webXmlConfiguration = new WebXmlConfiguration();
    WebInfConfiguration _webInfConfiguration = new WebInfConfiguration();
    MetaInfConfiguration _metaInfConfiguration = new MetaInfConfiguration();
    it.setConfigurations(new Configuration[] { _annotationConfiguration, _webXmlConfiguration, _webInfConfiguration, _metaInfConfiguration });
    it.setAttribute(WebInfConfiguration.CONTAINER_JAR_PATTERN, ".*/com\\.hribol\\.bromium\\.dsl\\.web/.*,.*\\.jar");
    it.setInitParameter("org.mortbay.jetty.servlet.Default.useFileMappedBuffer", "false");
  };
  WebAppContext _doubleArrow = ObjectExtensions.<WebAppContext>operator_doubleArrow(_webAppContext, _function);
  server.setHandler(_doubleArrow);
  String _name = ServerLauncher.class.getName();
  final Slf4jLog log = new Slf4jLog(_name);
  try {
    server.start();
    URI _uRI = server.getURI();
    String _plus = ("Server started " + _uRI);
    String _plus_1 = (_plus + "...");
    log.info(_plus_1);
    final Runnable _function_1 = () -> {
      try {
        log.info("Press enter to stop the server...");
        final int key = System.in.read();
        if ((key != (-1))) {
          server.stop();
        } else {
          log.warn("Console input is not available. In order to stop the server, you need to cancel process manually.");
        }
      } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
      }
    };
    new Thread(_function_1).start();
    server.join();
  } catch (final Throwable _t) {
    if (_t instanceof Exception) {
      final Exception exception = (Exception)_t;
      log.warn(exception.getMessage());
      System.exit(1);
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
}
 
Example 16
Source File: WebServerTools.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public static Server start(WebServer webServer) throws Exception {

		/**
		 * 更新x_desktop的center指向
		 */
		updateCenterConfigJson();
		/**
		 * 更新 favicon.ico
		 */
		updateFavicon();
		/**
		 * 创建index.html
		 */
		createIndexPage();

		QueuedThreadPool threadPool = new QueuedThreadPool();
		threadPool.setMinThreads(WEBSERVER_THREAD_POOL_SIZE_MIN);
		threadPool.setMaxThreads(WEBSERVER_THREAD_POOL_SIZE_MAX);
		Server server = new Server(threadPool);
		if (webServer.getSslEnable()) {
			addHttpsConnector(server, webServer.getPort());
		} else {
			addHttpConnector(server, webServer.getPort());
		}
		WebAppContext context = new WebAppContext();
		context.setContextPath("/");
		context.setBaseResource(Resource.newResource(new File(Config.base(), "servers/webServer")));
		// context.setResourceBase(".");
		context.setParentLoaderPriority(true);
		context.setExtractWAR(false);
		// context.setDefaultsDescriptor(new File(Config.base(),
		// "commons/webdefault_w.xml").getAbsolutePath());
		context.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "" + webServer.getDirAllowed());
		context.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
		if (webServer.getCacheControlMaxAge() > 0) {
			context.setInitParameter("org.eclipse.jetty.servlet.Default.cacheControl",
					"max-age=" + webServer.getCacheControlMaxAge());
		}
		context.setInitParameter("org.eclipse.jetty.servlet.Default.maxCacheSize", "256000000");
		context.setInitParameter("org.eclipse.jetty.servlet.Default.maxCachedFileSize", "200000000");
		context.setWelcomeFiles(new String[] { "default.html", "index.html" });
		context.setGzipHandler(new GzipHandler());
		context.setParentLoaderPriority(true);
		context.getMimeTypes().addMimeMapping("wcss", "application/json");
		/* stat */
		if (webServer.getStatEnable()) {
			FilterHolder statFilterHolder = new FilterHolder(new WebStatFilter());
			statFilterHolder.setInitParameter("exclusions", webServer.getStatExclusions());
			context.addFilter(statFilterHolder, "/*", EnumSet.of(DispatcherType.REQUEST));
			ServletHolder statServletHolder = new ServletHolder(StatViewServlet.class);
			statServletHolder.setInitParameter("sessionStatEnable", "false");
			context.addServlet(statServletHolder, "/druid/*");
		}
		/* stat end */
		server.setHandler(context);
		server.setDumpAfterStart(false);
		server.setDumpBeforeStop(false);
		server.setStopAtShutdown(true);
		server.start();

		context.setMimeTypes(Config.mimeTypes());
		System.out.println("****************************************");
		System.out.println("* web server start completed.");
		System.out.println("* port: " + webServer.getPort() + ".");
		System.out.println("****************************************");
		return server;
	}
 
Example 17
Source File: EmbeddedJettyServer.java    From Alpine with Apache License 2.0 4 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final CliArgs cliArgs = new CliArgs(args);
    final String contextPath = cliArgs.switchValue("-context", "/");
    final String host = cliArgs.switchValue("-host", "0.0.0.0");
    final int port = cliArgs.switchIntegerValue("-port", 8080);

    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();

    final Server server = new Server();
    final HttpConfiguration httpConfig = new HttpConfiguration();
    httpConfig.addCustomizer( new org.eclipse.jetty.server.ForwardedRequestCustomizer() ); // Add support for X-Forwarded headers

    final HttpConnectionFactory connectionFactory = new HttpConnectionFactory( httpConfig );
    final ServerConnector connector = new ServerConnector(server, connectionFactory);
    connector.setHost(host);
    connector.setPort(port);
    disableServerVersionHeader(connector);
    server.setConnectors(new Connector[]{connector});

    final WebAppContext context = new WebAppContext();
    context.setServer(server);
    context.setContextPath(contextPath);
    context.setErrorHandler(new ErrorHandler());
    context.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
    context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*taglibs.*\\.jar$");
    context.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
    context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
    context.addBean(new ServletContainerInitializersStarter(context), true);

    // Prevent loading of logging classes
    context.getSystemClasspathPattern().add("org.apache.log4j.");
    context.getSystemClasspathPattern().add("org.slf4j.");
    context.getSystemClasspathPattern().add("org.apache.commons.logging.");

    final ProtectionDomain protectionDomain = EmbeddedJettyServer.class.getProtectionDomain();
    final URL location = protectionDomain.getCodeSource().getLocation();
    context.setWar(location.toExternalForm());

    server.setHandler(context);
    server.addBean(new ErrorHandler());
    try {
        server.start();
        addJettyShutdownHook(server);
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(-1);
    }
}