Example usage for java.net BindException getCause

List of usage examples for java.net BindException getCause

Introduction

In this page you can find the example usage for java.net BindException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:edu.stanford.epad.epadws.PluginMain.java

public static void main(String[] args) {
    ShutdownSignal shutdownSignal = ShutdownSignal.getInstance();
    Server server = null;//from  w w  w .  jav  a 2s. com

    try {
        checkPluginsFile();
        int pluginPort = new Integer(EPADConfig.getParamValue("PluginPort", "8085"));
        log.info("#######################################################");
        log.info("############# Starting ePAD Plugin Webapp #############");
        log.info("#######################################################");
        initializePlugins();
        server = new Server(pluginPort);
        configureJettyServer(server);
        addHandlers(server);
        Runtime.getRuntime().addShutdownHook(new ShutdownHookThread());
        log.info("Starting Jetty for ePAD Plugins on port " + pluginPort);
        server.start();
        server.join();
    } catch (BindException be) {
        log.severe("Bind exception", be);
        Throwable t = be.getCause();
        log.warning("Bind exception cause: " + be.getMessage(), t);
    } catch (SocketException se) {
        log.severe("Cannot bind to all sockets", se);
    } catch (Exception e) {
        log.severe("Fatal Exception. Shutting down ePAD Web Service", e);
    } catch (Error err) {
        log.severe("Fatal Error. Shutting down ePAD Web Service", err);
    } finally {
        log.info("#####################################################");
        log.info("############# Shutting down ePAD  ###################");
        log.info("#####################################################");

        shutdownSignal.shutdownNow();
        stopServer(server);
        try { // Wait just long enough for some messages to be printed out.
            TimeUnit.MILLISECONDS.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    log.info("#####################################################");
    log.info("################## Exit ePAD Web Service ###########");
    log.info("#####################################################");
}

From source file:edu.stanford.epad.epadws.Main.java

public static void main(String[] args) {
    ShutdownSignal shutdownSignal = ShutdownSignal.getInstance();
    Server server = null;//w w w.jav a  2 s.c o m

    try {
        checkPropertiesFile();
        checkResourcesFolders();
        checkPluginsFile();
        RemotePACService.checkPropertiesFile();
        int epadPort = EPADConfig.epadPort;
        Dcm4CheeOperations.checkScriptFiles();
        separateWebServicesApp = "true".equalsIgnoreCase(EPADConfig.getParamValue("SeparateWebServicesApp"));
        if (!separateWebServicesApp) {
            log.info("#####################################################");
            log.info("############# Starting ePAD Web Service #############");
            log.info("#####################################################");
            initializePlugins();
            startSupportThreads();
        } else {
            log.info("#####################################################");
            log.info("############# Starting ePAD GWT FrontEnd ############");
            log.info("#####################################################");
        }
        server = new Server(epadPort);
        configureJettyServer(server);
        addHandlers(server);
        Runtime.getRuntime().addShutdownHook(new ShutdownHookThread());
        log.info("Starting Jetty on port " + epadPort);
        server.start();
        setupTestFiles();
        server.join();
    } catch (BindException be) {
        log.severe("Bind exception", be);
        Throwable t = be.getCause();
        log.warning("Bind exception cause: " + be.getMessage(), t);
    } catch (SocketException se) {
        log.severe("Cannot bind to all sockets", se);
    } catch (Exception e) {
        log.severe("Fatal Exception. Shutting down ePAD Web Service", e);
    } catch (Error err) {
        log.severe("Fatal Error. Shutting down ePAD Web Service", err);
    } finally {
        log.info("#####################################################");
        log.info("############# Shutting down ePAD  ###################");
        log.info("#####################################################");

        shutdownSignal.shutdownNow();
        stopServer(server);
        if (!separateWebServicesApp) {
            EpadDatabase.getInstance().shutdown();
            QueueAndWatcherManager.getInstance().shutdown();
        }
        try { // Wait just long enough for some messages to be printed out.
            TimeUnit.MILLISECONDS.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    log.info("#####################################################");
    log.info("################## Exit ePAD Web Service ###########");
    log.info("#####################################################");
}