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

The following examples show how to use org.eclipse.jetty.webapp.WebAppContext#setResourceBase() . 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: MetricServer.java    From realtime-analytics with GNU General Public License v2.0 6 votes vote down vote up
public void startStandAlone() {
    try {
        WebAppContext context = new WebAppContext();
        String baseUrl = getBaseUrl();
        LOGGER.info("Metric server baseUrl: " + baseUrl);
        context.setDescriptor(baseUrl + "/WEB-INF/web.xml");
        context.setResourceBase(baseUrl);
        context.setContextPath("/");
        context.setParentLoaderPriority(true);
        context.setAttribute("JetStreamRoot", applicationContext);
        Server s_server = new Server(s_port);
        s_server.setHandler(context);

        LOGGER.info( "Metric server started, listening on port " + s_port);
        s_server.start();
        running.set(true);
    } catch (Throwable t) {
        throw CommonUtils.runtimeException(t);
    }
}
 
Example 2
Source File: JettyFactory.java    From java-tutorial with Creative Commons Attribution Share Alike 4.0 International 6 votes vote down vote up
public static void initWebAppContext(Server server, int type) throws Exception {
	System.out.println("[INFO] Application loading");
	WebAppContext webAppContext = (WebAppContext) server.getHandler();
	webAppContext.setContextPath(CONTEXT);
	webAppContext.setResourceBase(getAbsolutePath() + RESOURCE_BASE_PATH);
	webAppContext.setDescriptor(getAbsolutePath() + RESOURCE_BASE_PATH + WEB_XML_PATH);

	if (IDE_INTELLIJ == type) {
		webAppContext.setDefaultsDescriptor(WINDOWS_WEBDEFAULT_PATH);
		supportJspAndSetTldJarNames(server, TLD_JAR_NAMES);
	} else {
		webAppContext.setParentLoaderPriority(true);
	}

	System.out.println("[INFO] Application loaded");
}
 
Example 3
Source File: JettyFactory.java    From java-tutorial with Creative Commons Attribution Share Alike 4.0 International 6 votes vote down vote up
public static void initWebAppContext(Server server, int type) throws Exception {
	System.out.println("[INFO] Application loading");
	WebAppContext webAppContext = (WebAppContext) server.getHandler();
	webAppContext.setContextPath(CONTEXT);
	webAppContext.setResourceBase(getAbsolutePath() + RESOURCE_BASE_PATH);
	webAppContext.setDescriptor(getAbsolutePath() + RESOURCE_BASE_PATH + WEB_XML_PATH);

	if (IDE_INTELLIJ == type) {
		webAppContext.setDefaultsDescriptor(WINDOWS_WEBDEFAULT_PATH);
		supportJspAndSetTldJarNames(server, TLD_JAR_NAMES);
	} else {
		webAppContext.setParentLoaderPriority(true);
	}

	System.out.println("[INFO] Application loaded");
}
 
Example 4
Source File: JettyEmbedServer.java    From tddl5 with Apache License 2.0 6 votes vote down vote up
public void start() throws Exception {
    Resource configXml = Resource.newSystemResource(config);
    XmlConfiguration configuration = new XmlConfiguration(configXml.getInputStream());
    server = (Server) configuration.configure();

    // Integer port = getPort();
    // if (port != null && port > 0) {
    // Connector[] connectors = server.getConnectors();
    // for (Connector connector : connectors) {
    // connector.setPort(port);
    // }
    // }
    Handler handler = server.getHandler();
    if (handler != null && handler instanceof WebAppContext) {
        WebAppContext webAppContext = (WebAppContext) handler;
        webAppContext.setResourceBase(JettyEmbedServer.class.getResource("/webapp").toString());
    }
    server.start();
    if (logger.isInfoEnabled()) {
        logger.info("##Jetty Embed Server is startup!");
    }
}
 
Example 5
Source File: RunApp.java    From titan-web-example with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    System.out.println("Working directory: " + new File("./").getAbsolutePath().toString());
    Server server = new Server(9091);

    WebAppContext context = new WebAppContext();
    context.setDescriptor("/WEB-INF/web.xml");
    context.setResourceBase("src/main/webapp");
    context.setContextPath("/");
    context.setParentLoaderPriority(true);

    context.addServlet(DefaultServlet.class, "/*");
    server.setHandler(context);

    server.start();
    server.join();

}
 
Example 6
Source File: JettyStart.java    From AppStash with Apache License 2.0 6 votes vote down vote up
public static void main(final String[] args) {
    if (args.length < 1) {
        System.out.println("JettyStart <httpport>");
        return;
    }

    Validate.notNull(args[0], "A Port is needed to start the server");

    Server server = new Server(Integer.valueOf(args[0]));
    WebAppContext context = new WebAppContext();
    context.setContextPath("/shop");
    context.setResourceBase("src/main/webapp/");
    context.setDescriptor("src/main/webapp/WEB-INF/web.xml");
    context.setParentLoaderPriority(true);
    server.setHandler(context);

    try {
        LOGGER.info("JETTY SERVER STARTING NOW ...");
        server.start();
        server.join();
    } catch (Exception e) {
        LOGGER.error("Jetty Server could not be started", e);
        System.exit(100);
    }
}
 
Example 7
Source File: CommandServerUnitTest.java    From Scribengin with GNU Affero General Public License v3.0 6 votes vote down vote up
@BeforeClass
public static void setup() throws Exception{
  //Bring up ZK and all that jazz
  CommandServerTestBase.setup();

  Registry registry = CommandServerTestBase.getNewRegistry();
  try {
    registry.connect();
  } catch (RegistryException e) {
    e.printStackTrace();
  }
  
  cs = new CommandServer(port);
  //Point our context to our web.xml we want to use for testing
  WebAppContext webapp = new WebAppContext();
  webapp.setResourceBase(CommandServerTestBase.getCommandServerFolder());
  webapp.setDescriptor(CommandServerTestBase.getCommandServerXml());
  cs.setHandler(webapp);
  cs.startServer();
}
 
Example 8
Source File: ApiIT.java    From greenmail with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUp() throws Exception {
    // Check if executed inside target directory or module directory
    String pathPrefix =new File(".").getCanonicalFile().getName().equals("target") ? "../" : "./";

    server = new Server();
    ServerConnector connector = new ServerConnector(server);
    connector.setPort(18080);
    connector.setHost("localhost");
    server.setConnectors(new Connector[]{connector});

    WebAppContext context = new WebAppContext();
    context.setDescriptor(pathPrefix + "src/main/webapp/WEB-INF/web.xml");
    context.setResourceBase(pathPrefix + "src/main/webapp");
    context.setContextPath("/");
    context.setParentLoaderPriority(true);

    server.setHandler(context);

    server.start();

    client = ClientBuilder.newClient();
    root = client.target("http://" + connector.getHost() + ':' + connector.getPort() + '/');
}
 
Example 9
Source File: CommandProxyServletRetryUnitTest.java    From Scribengin with GNU Affero General Public License v3.0 6 votes vote down vote up
@Before
public void setup() throws Exception{
  //Bring up ZK and all that jazz
  CommandServerTestBase.setup();

  registry = CommandServerTestBase.getNewRegistry();
  try {
    registry.connect();
  } catch (RegistryException e) {
    e.printStackTrace();
  }
  
  //Add the entry to tell the proxy server where to go to find the commandServer
  registry.create(registryPath, ("http://localhost:"+Integer.toString(commandPort)).getBytes(), NodeCreateMode.PERSISTENT);
  
  //Start proxy
  WebAppContext proxyApp = new WebAppContext();
  proxyApp.setResourceBase(CommandServerTestBase.getProxyServerFolder());
  proxyApp.setDescriptor(  CommandServerTestBase.getProxyServerXml());
  
  proxyServer = new JettyServer(proxyPort, CommandProxyServlet.class);
  proxyServer.setHandler(proxyApp);
  proxyServer.start();
}
 
Example 10
Source File: WebServerTestCase.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Starts the web server delivering response from the provided connection.
 * @param mockConnection the sources for responses
 * @throws Exception if a problem occurs
 */
protected void startWebServer(final MockWebConnection mockConnection) throws Exception {
    if (STATIC_SERVER_ == null) {
        final Server server = buildServer(PORT);

        final WebAppContext context = new WebAppContext();
        context.setContextPath("/");
        context.setResourceBase("./");

        if (isBasicAuthentication()) {
            final Constraint constraint = new Constraint();
            constraint.setName(Constraint.__BASIC_AUTH);
            constraint.setRoles(new String[]{"user"});
            constraint.setAuthenticate(true);

            final ConstraintMapping constraintMapping = new ConstraintMapping();
            constraintMapping.setConstraint(constraint);
            constraintMapping.setPathSpec("/*");

            final ConstraintSecurityHandler handler = (ConstraintSecurityHandler) context.getSecurityHandler();
            handler.setLoginService(new HashLoginService("MyRealm", "./src/test/resources/realm.properties"));
            handler.setConstraintMappings(new ConstraintMapping[]{constraintMapping});
        }

        context.addServlet(MockWebConnectionServlet.class, "/*");
        server.setHandler(context);

        tryStart(PORT, server);
        STATIC_SERVER_ = server;
    }
    MockWebConnectionServlet.setMockconnection(mockConnection);
}
 
Example 11
Source File: RESTInterface.java    From nadia with Apache License 2.0 5 votes vote down vote up
@Override
public void start(){
	try{
		NadiaProcessorConfig config = NadiaProcessorConfig.getInstance();
		
		//Jetty:
		server = new Server();
		
		//main config
        WebAppContext context = new WebAppContext();
        context.setDescriptor(config.getProperty(NadiaProcessorConfig.JETTYWEBXMLPATH));
        context.setResourceBase(config.getProperty(NadiaProcessorConfig.JETTYRESOURCEBASE));
        context.setContextPath(config.getProperty(NadiaProcessorConfig.JETTYCONTEXTPATH));
        context.setParentLoaderPriority(true);
        server.setHandler(context);
        
        //ssl (https)
        SslContextFactory sslContextFactory = new SslContextFactory(config.getProperty(NadiaProcessorConfig.JETTYKEYSTOREPATH));
        sslContextFactory.setKeyStorePassword(config.getProperty(NadiaProcessorConfig.JETTYKEYSTOREPASS));

        ServerConnector serverconn = new ServerConnector(server, sslContextFactory);
        serverconn.setPort(8080); //443 (or 80) not allowed on Linux unless run as root
        server.setConnectors(new Connector[] {serverconn});
        
        //start	        
        server.start();
        logger.info("REST interface started on "+server.getURI());
        server.join();
		
	}
	catch(Exception ex){
		ex.printStackTrace();
		logger.severe("Nadia: failed to start Jetty: "+ex.getMessage());
		server.destroy();
	}
}
 
Example 12
Source File: VRaptorServer.java    From mamute with Apache License 2.0 5 votes vote down vote up
private static WebAppContext loadContext(String webappDirLocation, String webXmlLocation) {
	WebAppContext context = new WebAppContext();
	context.setContextPath(getContext());
	context.setDescriptor(webXmlLocation);
	context.setResourceBase(webappDirLocation);
	context.setParentLoaderPriority(true);
	return context;
}
 
Example 13
Source File: ExampleServerR4IT.java    From hapi-fhir-jpaserver-starter with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
    String path = Paths.get("").toAbsolutePath().toString();

    ourLog.info("Project base path is: {}", path);

    ourServer = new Server(0);

    WebAppContext webAppContext = new WebAppContext();
    webAppContext.setContextPath("/hapi-fhir-jpaserver");
    webAppContext.setDisplayName("HAPI FHIR");
    webAppContext.setDescriptor(path + "/src/main/webapp/WEB-INF/web.xml");
    webAppContext.setResourceBase(path + "/target/hapi-fhir-jpaserver-starter");
    webAppContext.setParentLoaderPriority(true);

    ourServer.setHandler(webAppContext);
    ourServer.start();

    ourPort = JettyUtil.getPortForStartedServer(ourServer);

    ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
    ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
    String ourServerBase = HapiProperties.getServerAddress();
    ourServerBase = "http://localhost:" + ourPort + "/hapi-fhir-jpaserver/fhir/";

    ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
    ourClient.registerInterceptor(new LoggingInterceptor(true));
}
 
Example 14
Source File: ExampleServerR5IT.java    From hapi-fhir-jpaserver-starter with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
    String path = Paths.get("").toAbsolutePath().toString();

    ourLog.info("Project base path is: {}", path);

    ourServer = new Server(0);

    WebAppContext webAppContext = new WebAppContext();
    webAppContext.setContextPath("/hapi-fhir-jpaserver");
    webAppContext.setDisplayName("HAPI FHIR");
    webAppContext.setDescriptor(path + "/src/main/webapp/WEB-INF/web.xml");
    webAppContext.setResourceBase(path + "/target/hapi-fhir-jpaserver-starter");
    webAppContext.setParentLoaderPriority(true);

    ourServer.setHandler(webAppContext);
    ourServer.start();

    ourPort = JettyUtil.getPortForStartedServer(ourServer);

    ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
    ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
    String ourServerBase = "http://localhost:" + ourPort + "/hapi-fhir-jpaserver/fhir/";

    ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
    ourClient.registerInterceptor(new LoggingInterceptor(true));
}
 
Example 15
Source File: WebApp.java    From json-schema-validator-demo with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(final String... args)
    throws Exception
{
    final String webappDirLocation = "src/main/webapp/";

    //The port that we should run on can be set into an environment variable
    //Look for that variable and default to 8080 if it isn't there.
    String webPort = System.getenv("PORT");
    if (Strings.isNullOrEmpty(webPort))
        webPort = "8080";

    final Server server = new Server(Integer.valueOf(webPort));
    final WebAppContext root = new WebAppContext();

    root.setContextPath("/");
    root.setDescriptor(webappDirLocation + "/WEB-INF/web.xml");
    root.setResourceBase(webappDirLocation);

    //Parent loader priority is a class loader setting that Jetty accepts.
    //By default Jetty will behave like most web containers in that it will
    //allow your application to replace non-server libraries that are part of the
    //container. Setting parent loader priority to true changes this behavior.
    //Read more here: http://wiki.eclipse.org/Jetty/Reference/Jetty_Classloading
    root.setParentLoaderPriority(true);

    server.setHandler(root);

    server.start();
    server.join();
}
 
Example 16
Source File: ClusterTest.java    From maven-framework-project with MIT License 4 votes vote down vote up
@Test
public void testCluster() throws Exception {
	
	String projectBaseDirectory = System.getProperty("user.dir");
	
	//
	// Create master node
	//
	Server masterServer = new Server(8080);

	WebAppContext masterContext = new WebAppContext();
	masterContext.setDescriptor(projectBaseDirectory + "/target/vaporware/WEB-INF/web.xml");
	masterContext.setResourceBase(projectBaseDirectory + "/target/vaporware");
	masterContext.setContextPath("/");
	masterContext.setConfigurations(
			new Configuration[] { 
					new WebInfConfiguration(),
					new WebXmlConfiguration(),
					new MetaInfConfiguration(), 
					new FragmentConfiguration(),
					new EnvConfiguration(),
					new PlusConfiguration(),
					new AnnotationConfiguration(), 
					new JettyWebXmlConfiguration(),
					new TagLibConfiguration()
			}
	);
	masterContext.setParentLoaderPriority(true);

	masterServer.setHandler(masterContext);
	masterServer.start();
	//masterServer.join();

	//
	// Create slave node
	//
	Server slaveServer = new Server(8181);

	WebAppContext slaveContext = new WebAppContext();
	slaveContext.setDescriptor(projectBaseDirectory + "/target/vaporware/WEB-INF/web-slave.xml");
	slaveContext.setResourceBase(projectBaseDirectory + "/target/vaporware");
	slaveContext.setContextPath("/");
	slaveContext.setConfigurations(
			new Configuration[] { 
					new WebInfConfiguration(),
					new WebXmlConfiguration(),
					new MetaInfConfiguration(), 
					new FragmentConfiguration(),
					new EnvConfiguration(),
					new PlusConfiguration(),
					new AnnotationConfiguration(), 
					new JettyWebXmlConfiguration(),
					new TagLibConfiguration()
			}
	);
	slaveContext.setParentLoaderPriority(true);

	slaveServer.setHandler(slaveContext);
	slaveServer.start();
	//slaveServer.join();
	
	// Try to let the user terminate the Jetty server instances gracefully.  This won't work in an environment like Eclipse, if 
	// console input can't be received.  However, even in that that case you will be able to kill the Maven process without 
	// a Java process lingering around (as would be the case if you used "Sever.join()" to pause execution of this thread).
	System.out.println("PRESS <ENTER> TO HALT SERVERS (or kill the Maven process)...");
	Scanner scanner = new Scanner(System.in);
	String line = scanner.nextLine();
	System.out.println(line);
	scanner.close();
	masterServer.stop();
	slaveServer.stop();
	System.out.println("Servers halted");
	
}
 
Example 17
Source File: JenkinsRule.java    From jenkins-test-harness with MIT License 4 votes vote down vote up
/**
 * Creates a web server on which Jenkins can run
 *
 * @param contextPath              the context path at which to put Jenkins
 * @param portSetter               the port on which the server runs will be set using this function
 * @param classLoader              the class loader for the {@link WebAppContext}
 * @param localPort                port on which the server runs
 * @param loginServiceSupplier     configures the {@link LoginService} for the instance
 * @param contextAndServerConsumer configures the {@link WebAppContext} and the {@link Server} for the instance, before they are started
 * @return ImmutablePair consisting of the {@link Server} and the {@link ServletContext}
 * @since 2.50
 */
public static ImmutablePair<Server, ServletContext> _createWebServer(String contextPath, Consumer<Integer> portSetter,
                                                                     ClassLoader classLoader, int localPort,
                                                                     Supplier<LoginService> loginServiceSupplier,
                                                                     @CheckForNull BiConsumer<WebAppContext, Server> contextAndServerConsumer)
        throws Exception {
    QueuedThreadPool qtp = new QueuedThreadPool();
    qtp.setName("Jetty (JenkinsRule)");
    Server server = new Server(qtp);

    WebAppContext context = new WebAppContext(WarExploder.getExplodedDir().getPath(), contextPath);
    context.setClassLoader(classLoader);
    context.setConfigurations(new Configuration[]{new WebXmlConfiguration()});
    context.addBean(new NoListenerConfiguration(context));
    server.setHandler(context);
    context.setMimeTypes(MIME_TYPES);
    context.getSecurityHandler().setLoginService(loginServiceSupplier.get());
    context.setResourceBase(WarExploder.getExplodedDir().getPath());

    ServerConnector connector = new ServerConnector(server);
    HttpConfiguration config = connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration();
    // use a bigger buffer as Stapler traces can get pretty large on deeply nested URL
    config.setRequestHeaderSize(12 * 1024);
    connector.setHost("localhost");
    if (System.getProperty("port") != null) {
        connector.setPort(Integer.parseInt(System.getProperty("port")));
    } else if (localPort != 0) {
        connector.setPort(localPort);
    }

    server.addConnector(connector);
    if (contextAndServerConsumer != null) {
        contextAndServerConsumer.accept(context, server);
    }
    server.start();

    portSetter.accept(connector.getLocalPort());

    ServletContext servletContext =  context.getServletContext();
    return new ImmutablePair<>(server, servletContext);
}
 
Example 18
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 19
Source File: JenkinsRuleNonLocalhost.java    From kubernetes-plugin with Apache License 2.0 4 votes vote down vote up
/**
 * Prepares a webapp hosting environment to get {@link javax.servlet.ServletContext} implementation
 * that we need for testing.
 */
protected ServletContext createWebServer() throws Exception {
    server = new Server(new ThreadPoolImpl(new ThreadPoolExecutor(10, 10, 10L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(),new ThreadFactory() {
        public Thread newThread(Runnable r) {
            Thread t = new Thread(r);
            t.setName("Jetty Thread Pool");
            return t;
        }
    })));

    WebAppContext context = new WebAppContext(WarExploder.getExplodedDir().getPath(), contextPath);
    context.setClassLoader(getClass().getClassLoader());
    context.setConfigurations(new Configuration[]{new WebXmlConfiguration()});
    context.addBean(new NoListenerConfiguration(context));
    server.setHandler(context);
    context.setMimeTypes(MIME_TYPES);
    context.getSecurityHandler().setLoginService(configureUserRealm());
    context.setResourceBase(WarExploder.getExplodedDir().getPath());

    ServerConnector connector = new ServerConnector(server);
    HttpConfiguration config = connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration();
    // use a bigger buffer as Stapler traces can get pretty large on deeply nested URL
    config.setRequestHeaderSize(12 * 1024);
    System.err.println("Listening on host address: " + HOST);
    connector.setHost(HOST);

    if (System.getProperty("port")!=null) {
        LOGGER.info("Overriding port using system property: " + System.getProperty("port"));
        connector.setPort(Integer.parseInt(System.getProperty("port")));
    } else {
        if (port != null) {
            connector.setPort(port);
        }
    }

    server.addConnector(connector);
    try {
        server.start();
    } catch (BindException e) {
        throw new BindException(String.format("Error binding to %s:%d %s", connector.getHost(), connector.getPort(),
                e.getMessage()));
    }

    localPort = connector.getLocalPort();
    LOGGER.log(Level.INFO, "Running on {0}", getURL());

    return context.getServletContext();
}
 
Example 20
Source File: ITJDBCDriverTest.java    From kylin with Apache License 2.0 3 votes vote down vote up
protected static void startJetty() throws Exception {

        server = new Server(PORT);

        WebAppContext context = new WebAppContext();
        context.setDescriptor("../server/src/main/webapp/WEB-INF/web.xml");
        context.setResourceBase("../server/src/main/webapp");
        context.setContextPath("/kylin");
        context.setParentLoaderPriority(true);

        server.setHandler(context);

        server.start();

    }