Example usage for java.lang Exception getMessage

List of usage examples for java.lang Exception getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.sm.test.TestError.java

public static void main(String[] args) throws Exception {
    String[] opts = new String[] { "-configPath", "-url", "-store", "-times" };
    String[] defaults = new String[] { "", "localhost:6172", "store1", "2" };
    String[] paras = getOpts(args, opts, defaults);

    String configPath = paras[0];
    if (configPath.length() == 0) {
        logger.error("missing config path or host");
        throw new RuntimeException("missing -configPath or -host");
    }/*w w  w.  j a  v a  2s  .c  o m*/

    String url = paras[1];
    String store = paras[2];
    int times = Integer.valueOf(paras[3]);
    ClusterClientFactory ccf = ClusterClientFactory.connect(url, store);
    ClusterClient client = ccf.getDefaultStore(8000L);
    TestError testClient = new TestError(client);
    for (int i = 0; i < times; i++) {
        try {
            Key key = Key.createKey("test" + i);
            //client.put(key, "times-" + i);
            Value value = client.get(key);
            value.setVersion(value.getVersion() - 2);
            client.put(key, value);
            logger.info(value == null ? "null" : value.getData().toString());
        } catch (Exception ex) {
            logger.error(ex.getMessage(), ex);
        }
    }
    testClient.client.close();
    ccf.close();
}

From source file:ee.ria.xroad.confproxy.commandline.ConfProxyUtilMain.java

/**
 * Configuration proxy utility tool program entry point.
 * @param args program args/* w w w . ja  v  a2s . c  om*/
 */
public static void main(final String[] args) {
    try {
        setup();
        runUtilWithArgs(args);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        log.error("Error while running confproxy util:", e);
    } finally {
        actorSystem.shutdown();
    }
}

From source file:org.schemaspy.Main.java

public static void main(String[] argv) throws Exception {
    Logger logger = Logger.getLogger(Main.class.getName());

    final AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(
            "org.schemaspy.service");
    applicationContext.register(SchemaAnalyzer.class);

    if (argv.length == 1 && "-gui".equals(argv[0])) { // warning: serious temp hack
        new MainFrame().setVisible(true);
        return;/*from   w  w  w .java 2 s  . com*/
    }

    SchemaAnalyzer analyzer = applicationContext.getBean(SchemaAnalyzer.class);

    int rc = 1;

    try {
        rc = analyzer.analyze(new Config(argv)) == null ? 1 : 0;
    } catch (ConnectionFailure couldntConnect) {
        logger.log(Level.WARNING, "Connection Failure", couldntConnect);
        rc = 3;
    } catch (EmptySchemaException noData) {
        logger.log(Level.WARNING, "Empty schema", noData);
        rc = 2;
    } catch (InvalidConfigurationException badConfig) {
        logger.info("");
        if (badConfig.getParamName() != null)
            logger.log(Level.WARNING, "Bad parameter specified for " + badConfig.getParamName());
        logger.log(Level.WARNING, "Bad config " + badConfig.getMessage());
        if (badConfig.getCause() != null && !badConfig.getMessage().endsWith(badConfig.getMessage()))
            logger.log(Level.WARNING, " caused by " + badConfig.getCause().getMessage());

        logger.log(Level.FINE, "Command line parameters: " + Arrays.asList(argv));
        logger.log(Level.FINE, "Invalid configuration detected", badConfig);
    } catch (ProcessExecutionException badLaunch) {
        logger.log(Level.WARNING, badLaunch.getMessage(), badLaunch);
    } catch (Exception exc) {
        logger.log(Level.SEVERE, exc.getMessage(), exc);
    }

    System.exit(rc);
}

From source file:org.mzd.shap.spring.cli.Index.java

public static void main(String[] args) {
    if (args.length != 0) {
        System.out.println(USAGE_MSG);
        System.exit(1);/* w  w w  .  j  av  a 2 s .  co  m*/
    }

    try {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("datasource-context.xml",
                "orm-massindex-context.xml");

        SessionFactory sessionFactory = (SessionFactory) ctx.getBean("sessionFactory");
        Session session = sessionFactory.openSession();

        System.out.println(BEGIN_MSG);
        LOGGER.info(BEGIN_MSG);

        // Index single-threaded. Appear to have problems with collections.
        Search.getFullTextSession(session).createIndexer().batchSizeToLoadObjects(30)
                .threadsForSubsequentFetching(4).threadsToLoadObjects(2).cacheMode(CacheMode.NORMAL)
                .optimizeOnFinish(true).startAndWait();

        //LOGGER.debug(Reporting.reportQueryCacheStatistics(sessionFactory));
        //LOGGER.debug(Reporting.reportSecondLevleCacheStatistics(sessionFactory));

        System.out.println(FINISH_MSG);
        LOGGER.info(FINISH_MSG);

        System.exit(0);
    } catch (Exception ex) {
        System.err.println(ERROR_MSG + " [" + ex.getMessage() + "]");
        LOGGER.debug(ERROR_MSG, ex);
    }
}

From source file:TestBatchUpdate.java

public static void main(String args[]) {
    Connection conn = null;/*from  ww w . jav  a 2s. c  o m*/
    Statement stmt = null;
    ResultSet rs = null;
    try {
        conn = getConnection();
        stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        conn.setAutoCommit(false);
        stmt.addBatch("INSERT INTO batch_table(id, name) VALUES('11', 'A')");
        stmt.addBatch("INSERT INTO batch_table(id, name) VALUES('22', 'B')");
        stmt.addBatch("INSERT INTO batch_table(id, name) VALUES('33', 'C')");
        int[] updateCounts = stmt.executeBatch();
        conn.commit();

        rs = stmt.executeQuery("SELECT * FROM batch_table");
        while (rs.next()) {
            String id = rs.getString("id");
            String name = rs.getString("name");
            System.out.println("id=" + id + "  name=" + name);
        }

    } catch (BatchUpdateException b) {
        System.err.println("SQLException: " + b.getMessage());
        System.err.println("SQLState: " + b.getSQLState());
        System.err.println("Message: " + b.getMessage());
        System.err.println("Vendor error code: " + b.getErrorCode());
        System.err.print("Update counts: ");
        int[] updateCounts = b.getUpdateCounts();
        for (int i = 0; i < updateCounts.length; i++) {
            System.err.print(updateCounts[i] + " ");
        }
    } catch (SQLException ex) {
        System.err.println("SQLException: " + ex.getMessage());
        System.err.println("SQLState: " + ex.getSQLState());
        System.err.println("Message: " + ex.getMessage());
        System.err.println("Vendor error code: " + ex.getErrorCode());
    } catch (Exception e) {
        System.err.println("Exception: " + e.getMessage());
    } finally {
        try {
            rs.close();
            stmt.close();
            conn.close();
        } catch (Exception ignore) {
        }
    }
}

From source file:com.turn.ttorrent.cli.TrackerMain.java

/**
 * Main function to start a tracker./*  www . j a  v a 2s . c  o m*/
 */
public static void main(String[] args) throws Exception {
    // BasicConfigurator.configure(new ConsoleAppender(new PatternLayout("%d [%-25t] %-5p: %m%n")));

    OptionParser parser = new OptionParser();
    OptionSpec<Void> helpOption = parser.accepts("help").forHelp();
    OptionSpec<File> fileOption = parser.acceptsAll(Arrays.asList("file", "directory")).withRequiredArg()
            .ofType(File.class).required().describedAs("The list of torrent directories or files to announce.");
    OptionSpec<Integer> portOption = parser.accepts("port").withRequiredArg().ofType(Integer.class)
            .defaultsTo(Tracker.DEFAULT_TRACKER_PORT).required().describedAs("The port to listen on.");
    parser.nonOptions().ofType(File.class);

    OptionSet options = parser.parse(args);
    List<?> otherArgs = options.nonOptionArguments();

    // Display help and exit if requested
    if (options.has(helpOption)) {
        System.out.println("Usage: Tracker [<options>]");
        parser.printHelpOn(System.err);
        System.exit(0);
    }

    InetSocketAddress address = new InetSocketAddress(options.valueOf(portOption));
    Tracker t = new Tracker(address);
    try {
        for (File file : options.valuesOf(fileOption))
            addAnnounce(t, file, 0);
        logger.info("Starting tracker with {} announced torrents...", t.getTrackedTorrents().size());
        t.start();
    } catch (Exception e) {
        logger.error("{}", e.getMessage(), e);
        System.exit(2);
    } finally {
        t.stop();
    }
}

From source file:com.sm.store.TestRemotePopulate.java

public static void main(String[] args) {
    String[] opts = new String[] { "-store", "-url", "-times" };
    String[] defaults = new String[] { "campaignsperday", "las1-ssusd001.sm-us.sm.local:7240", "10" };
    String[] paras = getOpts(args, opts, defaults);
    String store = paras[0];//  w  w  w  . j a  v  a2s  .  co m
    String url = paras[1];
    int times = Integer.valueOf(paras[2]);
    HessianSerializer serializer = new HessianSerializer();

    RemotePersistence client = new NTRemoteClientImpl(url, null, store);
    for (int i = 0; i < times; i++) {
        try {
            //Key key = Key.createKey("cmp"+i);
            //Campaign campaign = new Campaign(1, 1, i, false, false, "test"+i, null, null, null, null, null);
            //logger.info(campaign);
            //byte[] campaignBytes = serializer.toBytes(campaign);
            // Value val = new RemoteValue(campaignBytes, 0, (short) 0);

            Key key = Key.createKey("usr" + i);
            List<String> campaignIds = new ArrayList<String>();
            campaignIds.add("cmp" + i);
            ////campaignIds.add("cmp"+i+i);
            //byte[] campaignIdsBytes = serializer.toBytes(campaignIds);
            Value val = new RemoteValue(campaignIds, 0, (short) 0);
            //
            //                   Key key = Key.createKey("cmp"+i+"."+20130116);
            //                   Delivery delivery = new Delivery(i, i+1, i*2, (i*2)+1, i*3, (i*3)+1, i*4, (i*4)+1, i*5, (i*5)+1);
            //                   byte[] deliveryBytes = serializer.toBytes(delivery);
            //                  Value val = new RemoteValue(deliveryBytes, 0, (short) 0);
            //                   client.put( key, val);
            //
            //                   key = Key.createKey("cmp"+i+"."+20130117);
            //                   delivery = new Delivery(i, i+2, i*2, (i*2)+2, i*3, (i*3)+2, i*4, (i*4)+2, i*5, (i*5)+2);
            //                   deliveryBytes = serializer.toBytes(delivery);
            //                  val = new RemoteValue(deliveryBytes, 0, (short) 0);

            client.put(key, val);

            Value value = client.get(key);
            logger.info("campaign value data: " + (List<String>) value.getData());
            logger.info(value == null ? "null" : value.getData().toString());

        } catch (Exception ex) {
            logger.error(ex.getMessage(), ex);
        }

    }
    client.close();

}

From source file:com.zimbra.qa.unittest.TestWsdlServlet.java

/**
 * @param args//from w w  w . java 2  s . c  o m
 */
public static void main(String[] args) throws Exception {
    TestUtil.cliSetup();
    try {
        TestUtil.runTest(TestWsdlServlet.class);
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }

}

From source file:com.zergiu.tvman.TVMan.java

public static void main(String[] args) {
    try {/*from ww  w  . j  a  va 2s .c  o  m*/
        TVManOptions options = TVManOptions.getInstance();
        options.parseCommandLine(args);
        configureLoggers(options);
        log.info("Starting TVMan .... ");
        final TVManWebServer server = new TVManWebServer();
        addShutdownHook(server);
        startServer(server);
    } catch (Exception e) {
        e.printStackTrace();
        log.error(e.getMessage(), e);
    }
}

From source file:de.mustnotbenamed.quickstart.undertowserver.Main.java

public static void main(String[] args) {
    CommandLine cmd = null;/*from w  ww  .j  a  v a2s.c om*/

    try {
        CommandLineParser parser = new GnuParser();
        cmd = parser.parse(createCliOption(), args);
    } catch (Exception e) {
        System.err.println("Failed to parse options: " + e.getMessage());
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("webapp", createCliOption());

        System.err.println("\n");
        System.err.println("### DEV ###");
        e.printStackTrace();

        System.exit(-1);
    }

    // start Webserver
    try {
        UndertowBootstrap.UndertowOptions options = new UndertowBootstrap.UndertowOptions();

        options.setHost(CliHelper.option(cmd, OPTION_HOST, options.getHost()));
        options.setPort(CliHelper.option(cmd, OPTION_PORT, options.getPort()));
        options.setContextPath(CliHelper.option(cmd, OPTION_CONTEXT_PATH, options.getContextPath()));

        new WeldUndertowBootstrap(options).startup();
    } catch (ParseException e) {
        throw new RuntimeException(e);
    }
}