Example usage for java.lang IllegalStateException getMessage

List of usage examples for java.lang IllegalStateException getMessage

Introduction

In this page you can find the example usage for java.lang IllegalStateException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.omade.monitor.ClientApplication.java

public static void main(String[] args) throws Exception {

    logger.info("program start ...");

    @SuppressWarnings("deprecation")
    CommandLineParser parser = new BasicParser();
    Options options = new Options();
    options.addOption("h", "help", false, "Print this usage information");
    options.addOption("c", "config", true, "configure the properties");
    options.addOption("v", "version", false, "Print out Version information");
    CommandLine commandLine = parser.parse(options, args);
    String configPath = "application.properties";

    if (commandLine.hasOption('h')) {
        logger.info("Help Message");
        System.exit(0);//w  w w  . j a  v  a 2 s.  com
    }

    if (commandLine.hasOption('v')) {
        logger.info("Version Message");
    }

    if (commandLine.hasOption('c')) {
        logger.info("Configuration Message");
        configPath = commandLine.getOptionValue('c');
        logger.info("configPath" + configPath);
        try {
            config = PropertiesUtil.getProperties(configPath);
        } catch (IllegalStateException e) {
            logger.error(e.getMessage());
            System.exit(-1);
        }
    }

    executeFixedRate();
}

From source file:org.jboss.as.jdr.CommandLineMain.java

/**
 * Creates a JBoss Diagnostic Reporter (JDR) Report. A JDR report response
 * is printed to <code>System.out</code>.
 *
 * @param args ignored/*w  w w  .  j  a  v a2 s. c om*/
 */
public static void main(String[] args) {
    int port = 9990;
    String host = "localhost";
    String protocol = "http-remoting";
    String config = null;
    try {
        CommandLine line = parser.parse(options, args, false);

        if (line.hasOption("help")) {
            formatter.printHelp(usage, NEW_LINE + JdrLogger.ROOT_LOGGER.jdrDescriptionMessage(), options, null);
            return;
        }
        if (line.hasOption("host")) {
            host = line.getOptionValue("host");
        }

        if (line.hasOption("port")) {
            port = Integer.parseInt(line.getOptionValue("port"));
        }

        if (line.hasOption("protocol")) {
            protocol = line.getOptionValue("protocol");
        }

        if (line.hasOption("config")) {
            config = line.getOptionValue("config");
        }
    } catch (ParseException e) {
        System.out.println(e.getMessage());
        formatter.printHelp(usage, options);
        return;
    } catch (NumberFormatException nfe) {
        System.out.println(nfe.getMessage());
        formatter.printHelp(usage, options);
        return;
    }

    System.out.println("Initializing JBoss Diagnostic Reporter...");

    // Try to run JDR on the Wildfly JVM
    CLI cli = CLI.newInstance();
    boolean embedded = false;
    JdrReport report = null;
    try {
        System.out.println(String.format("Trying to connect to %s %s:%s", protocol, host, port));
        cli.connect(protocol, host, port, null, null);
    } catch (IllegalStateException ex) {
        System.out.println("Starting embedded server");
        String startEmbeddedServer = "embed-server --std-out=echo "
                + ((config != null && !config.isEmpty()) ? (" --server-config=" + config) : "");
        cli.getCommandContext().handleSafe(startEmbeddedServer);
        embedded = true;
    }
    try {
        Result cmdResult = cli.cmd("/subsystem=jdr:generate-jdr-report()");
        ModelNode response = cmdResult.getResponse();
        if (Operations.isSuccessfulOutcome(response) || !embedded) {
            reportFailure(response);
            ModelNode result = response.get(ClientConstants.RESULT);
            report = new JdrReport(result);
        } else {
            report = standaloneCollect(cli, protocol, host, port);
        }
    } catch (IllegalStateException ise) {
        System.out.println(ise.getMessage());
        report = standaloneCollect(cli, protocol, host, port);
    } finally {
        if (cli != null) {
            try {
                if (embedded)
                    cli.getCommandContext().handleSafe("stop-embedded-server");
                else
                    cli.disconnect();
            } catch (Exception e) {
                System.out.println("Caught exception while disconnecting: " + e.getMessage());
            }
        }
    }
    printJdrReportInfo(report);
    System.exit(0);
}

From source file:net.sf.brunneng.iqdb.db.DBWorker.java

public static void main(String[] args) {
    Options options = new Options();

    Option actionOpt = new Option("a", "action", true, "The action on db, which should be executed." + BR_LINE
            + " Possible actions: " + BR_LINE + createActionsDescription());
    actionOpt.setRequired(true);//w  w w . j av  a 2  s  .  c  o m
    options.addOption(actionOpt);

    CommandLineParser parser = new GnuParser();
    try {
        CommandLine commandLine = parser.parse(options, args);

        String actionStr = commandLine.getOptionValue("action");
        DBAction action = null;
        try {
            action = DBAction.valueOf(actionStr);
        } catch (IllegalStateException exc) {
            System.out.println("Unknown action: " + actionStr);
            System.out.println("Possible actions: " + createActionsDescription());
            System.exit(-1);
        }

        DBWorker worker = new DBWorker(action, null, null, null);
        worker.execute();
    } catch (ParseException exc) {
        System.out.println("Unable to parse command line arguments. Error: " + exc.getMessage());
        printUsageAndExit(options);
    }
}

From source file:gov.loc.repository.bagger.app.BaggerApplication.java

public static void main(String[] args) {
    String rootContextDirectoryClassPath = "/gov/loc/repository/bagger/ctx";
    String startupContextPath = rootContextDirectoryClassPath + "/common/richclient-startup-context.xml";
    String richclientApplicationContextPath = rootContextDirectoryClassPath
            + "/common/richclient-application-context.xml";

    try {//from ww w .  j  a  v  a  2  s . c  om
        new ApplicationLauncher(startupContextPath, new String[] { richclientApplicationContextPath });
    } catch (IllegalStateException e) {

        log.error("IllegalStateException during startup", e);
        JOptionPane.showMessageDialog(null, "An illegal state error occured.\n", "Bagger startup error!",
                JOptionPane.ERROR_MESSAGE);
        System.exit(1);

    } catch (PropertyAccessException e) {

        log.error("PropertyAccessException during startup", e);
        JOptionPane.showMessageDialog(null, "An error occured loading properties.\n", "Bagger startup error!",
                JOptionPane.ERROR_MESSAGE);
        System.exit(1);

    } catch (RuntimeException e) {

        log.error("RuntimeException during startup", e);
        if (e.getMessage().contains("SAXParseException")) {
            JOptionPane.showMessageDialog(null,
                    "An error occured parsing application context.  You may have no internet access.\n",
                    "Bagger startup error!", JOptionPane.ERROR_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(null, "An error occured during startup.\n", "Bagger startup error!",
                    JOptionPane.ERROR_MESSAGE);
        }
        System.exit(1);

    }
}

From source file:org.cubictest.persistence.CustomTestStepPersistance.java

public static CustomTestStep loadFromFile(IProject project, String fileName) {
    if (project == null) {
        //try to get file without project
        return loadFromFile(new File(fileName));
    }/*from www .j  a v  a 2s . c o  m*/
    try {
        IFile ifile = project.getFile(new Path(fileName));
        return loadFromFile(ifile.getLocation().toFile());
    } catch (IllegalStateException e) {
        if (e.getMessage().indexOf("Workspace is closed") >= 0) {
            //Probably junit testing
            return loadFromFile(new File(fileName));
        }
    }
    throw new CubicException("Could not load custom step with file name = " + fileName);
}

From source file:com.bodybuilding.argos.controller.SseEmitterUtil.java

private static <T> void internalEmit(SseEmitter emitter, T data, MediaType mediaType) {
    try {/*from  w w w  .  j  a va  2 s .  c  o m*/
        if (mediaType == null) {
            emitter.send(data);
        } else {
            emitter.send(data, mediaType);
        }
    } catch (ClientAbortException ignored) {
    } catch (IllegalStateException e) {
        if (!e.getMessage().contains("ResponseBodyEmitter is already set complete")) {
            throw e;
        }
    } catch (Throwable e) {
        throw Throwables.propagate(e);
    }
}

From source file:com.goodway.nominatimparser.Request.java

public static void getPlaces(Action a, ArrayList<Pair>... parameters) {
    try {/*from  ww  w  . j a  va2 s. co m*/
        new GetPlaces(a, parameters).execute();
        Log.d("getPlaces", "getPlaces");
    } catch (IllegalStateException e) {
        Log.e(e.getMessage(), "exception");
    }

}

From source file:com.moarub.util.ShareMoreUtils.java

public static StringBuilder getResponseString(HttpResponse result) {
    if (result == null) {
        return null;
    }// w w  w  .j  ava  2s.co m
    StringBuilder builder = new StringBuilder("");

    HttpEntity res = result.getEntity();
    InputStream is = null;
    try {
        is = res.getContent();
    } catch (IllegalStateException e) {
        Log.d("ResponseString", "Response invalid (IllegalStateException) " + e.getMessage());
        return builder;
    } catch (IOException e) {
        Log.d("ResponseString", "Response invalid (IoException)  " + e.getMessage());
        return builder;
    }
    BufferedReader br = new BufferedReader(new InputStreamReader(is));

    String line = null;
    try {
        while ((line = br.readLine()) != null) {
            builder.append(line);
        }
    } catch (IOException e) {
        Log.d("ResponseString", "IOException " + e.getMessage());
        return builder;
    }
    return builder;
}

From source file:cn.jarlen.richcommon.ui.FragmentStack.java

public static void addFrament(FragmentActivity context, int containerId, Fragment newFragment) {
    try {/*from ww w.j a v a2s  . co  m*/
        FragmentManager fragmentManager = context.getSupportFragmentManager();
        FragmentTransaction ft = fragmentManager.beginTransaction();
        ft.setCustomAnimations(anim_In, anim_out);
        ft.add(containerId, newFragment, newFragment.getClass().getSimpleName()).commit();
    } catch (IllegalStateException e) {
        if (e.getMessage().startsWith("Fragment already added")) {
            removeFragment(context, newFragment);
            addFrament(context, containerId, newFragment);
        }
    }
}

From source file:org.cubictest.persistence.TestPersistance.java

/**
 * Loads tests with the given file name.
 * @param fileName//  w ww .  j  a va  2  s.  co  m
 * @return
 */
public static Test loadFromFile(IProject project, String fileName) {
    if (project == null) {
        //try to get file without project
        return loadFromFile(new File(fileName), null);
    }
    try {
        IFile testFile = project.getFile(new Path(fileName));
        return loadFromFile(testFile);
    } catch (IllegalStateException e) {
        if (e.getMessage().indexOf("Workspace is closed") >= 0) {
            //Probably junit testing
            return loadFromFile(new File(fileName), null);
        }
    }
    throw new CubicException("Could not load test with file name = " + fileName);
}