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:org.owasp.benchmark.tools.BenchmarkCrawler.java

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

    CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(getSSLFactory()).build();

    long start = System.currentTimeMillis();

    InputStream http = BenchmarkCrawler.class.getClassLoader()
            .getResourceAsStream("benchmark-crawler-http.xml");

    List<HttpPost> posts = parseHttpFile(httpclient, http);
    for (HttpPost post : posts) {
        try {// w ww  . ja  va 2s.co m
            sendPost(httpclient, post);
        } catch (Exception e) {
            System.err.println("\n  FAILED: " + e.getMessage());
            e.printStackTrace();
        }
    }

    long stop = System.currentTimeMillis();
    double seconds = (stop - start) / 1000;
    System.out.println("\n\nElapsed time " + seconds + " seconds");

}

From source file:edu.msu.cme.rdp.alignment.errorcheck.RmPartialSeqs.java

/**
* This program detects partial sequences based on the best pairwise alignment for each query sequence, 
* @param args/*from w w  w .java2 s .c  o m*/
* @throws Exception 
*/
public static void main(String[] args) throws Exception {

    String trainseqFile = null;
    String queryFile = null;
    PrintStream seqOutStream = null;
    PrintStream alignOutStream = null;
    AlignmentMode mode = AlignmentMode.overlap;
    int k = 10;
    int min_gaps = 50;

    try {
        CommandLine line = new PosixParser().parse(options, args);

        if (line.hasOption("alignment-mode")) {
            String m = line.getOptionValue("alignment-mode").toLowerCase();
            mode = AlignmentMode.valueOf(m);
        }

        if (line.hasOption("min_gaps")) {
            min_gaps = Integer.parseInt(line.getOptionValue("min_gaps"));
        }
        if (line.hasOption("knn")) {
            k = Integer.parseInt(line.getOptionValue("knn"));
        }
        if (line.hasOption("alignment-out")) {
            alignOutStream = new PrintStream(new File(line.getOptionValue("alignment-out")));
        }
        args = line.getArgs();
        if (args.length != 3) {
            throw new Exception("wrong number of arguments");
        }

        trainseqFile = args[0];
        queryFile = args[1];
        seqOutStream = new PrintStream(new File(args[2]));
    } catch (Exception e) {
        System.err.println("Error: " + e.getMessage());
        new HelpFormatter().printHelp(80,
                " [options] fulllengthSeqFile queryFile passedSeqOutFile\n  sequences can be either protein or nucleotide",
                "", options, "");
        return;
    }

    RmPartialSeqs theObj = new RmPartialSeqs(trainseqFile, queryFile, mode, k, min_gaps);

    theObj.checkPartial(seqOutStream, alignOutStream);
}

From source file:org.openspaces.focalserver.FocalServer.java

public static void main(String[] args) throws IOException {
    if (args.length < 1) {
        printUsage();//from   ww  w .  ja v  a  2 s . c  om
        System.exit(1);
    }
    LOGGER.info("\n==================================================\n"
            + "GigaSpaces Focal Server starting using " + Arrays.asList(args) + " \n" + "Log created by <"
            + System.getProperty("user.name") + "> on " + new Date().toString() + "\n"
            + "==================================================");
    ApplicationContext applicationContext;
    try {
        applicationContext = new FileSystemXmlApplicationContext(args);
    } catch (Exception e) {
        LOGGER.fine("Failed starting GigaSpaces Focal Server using " + Arrays.asList(args)
                + ", will try to load from classpath. " + e.getMessage());
        applicationContext = new ClassPathXmlApplicationContext(args);
    }

}

From source file:com.genentech.chemistry.tool.sdf2DAlign.java

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

    final String OPT_INFILE = "in";
    final String OPT_OUTFILE = "out";
    final String OPT_TEMPLATEFILE = "templates";
    final String OPT_RESETCOORDS = "reset";
    final String OPT_DEBUG = "debug";

    Options options = new Options();

    Option opt = new Option(OPT_INFILE, true, "Input file (oe-supported). Use .sdf to specify the file type.");
    opt.setRequired(true);/*  ww  w.j  a  va2 s.  c om*/
    options.addOption(opt);

    opt = new Option(OPT_OUTFILE, true, "Output file (oe-supported). Use .sdf to specify the file type.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_TEMPLATEFILE, true,
            "Template file (oe-supported). Use .sdf to specify the file type.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_RESETCOORDS, false,
            "Reset coordinates in input file when aligning. This will delete original 2D coords and create new ones.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_DEBUG, false, "Print debug statements.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("h", false, "print usage statement");
    opt.setRequired(false);
    options.addOption(opt);

    PosixParser parser = new PosixParser();
    CommandLine cl = null;

    try {
        cl = parser.parse(options, args);
    } catch (Exception exp) {
        System.err.println(exp.getMessage());
        exitWithHelp(options);
    }

    //get command line parameters
    String inFile = cl.getOptionValue(OPT_INFILE);
    String outFile = cl.getOptionValue(OPT_OUTFILE);
    String templateFile = cl.getOptionValue(OPT_TEMPLATEFILE);
    boolean resetCoords = cl.hasOption(OPT_RESETCOORDS);
    boolean debug = cl.hasOption(OPT_DEBUG);

    sdf2DAlign myAlign = new sdf2DAlign(inFile, outFile, templateFile, resetCoords);
    myAlign.setDebug(debug);

    //get templates as subsearches
    List<OESubSearch> templates = myAlign.getTemplates();

    //apply template to input molecules
    myAlign.applyTemplates(templates);

    for (OESubSearch ss : templates)
        ss.delete();
}

From source file:be.dnsbelgium.rdap.client.RDAPCLI.java

public static void main(String[] args) {

    LOGGER.debug("Create the command line parser");
    CommandLineParser parser = new GnuParser();

    LOGGER.debug("Create the options");
    Options options = new RDAPOptions(Locale.ENGLISH);

    try {//from   w w w.j av  a2 s  . com
        LOGGER.debug("Parse the command line arguments");
        CommandLine line = parser.parse(options, args);

        if (line.hasOption("help")) {
            printHelp(options);
            return;
        }

        if (line.getArgs().length == 0) {
            throw new IllegalArgumentException("You must provide a query");
        }
        String query = line.getArgs()[0];

        Type type = (line.getArgs().length == 2) ? Type.valueOf(line.getArgs()[1].toUpperCase())
                : guessQueryType(query);

        LOGGER.debug("Query: {}, Type: {}", query, type);

        try {
            SSLContextBuilder sslContextBuilder = SSLContexts.custom();
            if (line.hasOption(RDAPOptions.TRUSTSTORE)) {
                sslContextBuilder.loadTrustMaterial(
                        RDAPClient.getKeyStoreFromFile(new File(line.getOptionValue(RDAPOptions.TRUSTSTORE)),
                                line.getOptionValue(RDAPOptions.TRUSTSTORE_TYPE, RDAPOptions.DEFAULT_STORETYPE),
                                line.getOptionValue(RDAPOptions.TRUSTSTORE_PASS, RDAPOptions.DEFAULT_PASS)));
            }
            if (line.hasOption(RDAPOptions.KEYSTORE)) {
                sslContextBuilder.loadKeyMaterial(
                        RDAPClient.getKeyStoreFromFile(new File(line.getOptionValue(RDAPOptions.KEYSTORE)),
                                line.getOptionValue(RDAPOptions.KEYSTORE_TYPE, RDAPOptions.DEFAULT_STORETYPE),
                                line.getOptionValue(RDAPOptions.KEYSTORE_PASS, RDAPOptions.DEFAULT_PASS)),
                        line.getOptionValue(RDAPOptions.KEYSTORE_PASS, RDAPOptions.DEFAULT_PASS).toCharArray());
            }
            SSLContext sslContext = sslContextBuilder.build();

            final String url = line.getOptionValue(RDAPOptions.URL);
            final HttpHost host = Utils.httpHost(url);

            HashSet<Header> headers = new HashSet<Header>();
            headers.add(new BasicHeader("Accept-Language",
                    line.getOptionValue(RDAPOptions.LANG, Locale.getDefault().toString())));
            HttpClientBuilder httpClientBuilder = HttpClients.custom().setDefaultHeaders(headers)
                    .setSSLSocketFactory(new SSLConnectionSocketFactory(sslContext,
                            (line.hasOption(RDAPOptions.INSECURE) ? new AllowAllHostnameVerifier()
                                    : new BrowserCompatHostnameVerifier())));

            if (line.hasOption(RDAPOptions.USERNAME) && line.hasOption(RDAPOptions.PASSWORD)) {
                BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
                credentialsProvider.setCredentials(new AuthScope(host.getHostName(), host.getPort()),
                        new UsernamePasswordCredentials(line.getOptionValue(RDAPOptions.USERNAME),
                                line.getOptionValue(RDAPOptions.PASSWORD)));
                httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
            }

            RDAPClient rdapClient = new RDAPClient(httpClientBuilder.build(), url);
            ObjectMapper mapper = new ObjectMapper();

            JsonNode json = null;
            switch (type) {
            case DOMAIN:
                json = rdapClient.getDomainAsJson(query);
                break;
            case ENTITY:
                json = rdapClient.getEntityAsJson(query);
                break;
            case AUTNUM:
                json = rdapClient.getAutNum(query);
                break;
            case IP:
                json = rdapClient.getIp(query);
                break;
            case NAMESERVER:
                json = rdapClient.getNameserver(query);
                break;
            }
            PrintWriter out = new PrintWriter(System.out, true);
            if (line.hasOption(RDAPOptions.RAW)) {
                mapper.writer().writeValue(out, json);
            } else if (line.hasOption(RDAPOptions.PRETTY)) {
                mapper.writer(new DefaultPrettyPrinter()).writeValue(out, json);
            } else if (line.hasOption(RDAPOptions.YAML)) {
                DumperOptions dumperOptions = new DumperOptions();
                dumperOptions.setPrettyFlow(true);
                dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
                dumperOptions.setSplitLines(true);
                Yaml yaml = new Yaml(dumperOptions);
                Map data = mapper.convertValue(json, Map.class);
                yaml.dump(data, out);
            } else {
                mapper.writer(new MinimalPrettyPrinter()).writeValue(out, json);
            }
            out.flush();
        } catch (Exception e) {
            LOGGER.error(e.getMessage(), e);
            System.exit(-1);
        }
    } catch (org.apache.commons.cli.ParseException e) {
        printHelp(options);
        System.exit(-1);
    }
}

From source file:mx.unam.fesa.mss.MSSMain.java

/**
 * @param args//from  ww w .  ja  v  a  2  s  .co  m
 */
@SuppressWarnings("static-access")
public static void main(String[] args) {

    //
    // managing command line options using commons-cli
    //

    Options options = new Options();

    // help option
    //
    options.addOption(
            OptionBuilder.withDescription("Prints this message.").withLongOpt("help").create(OPT_HELP));

    // port option
    //
    options.addOption(OptionBuilder.withDescription("The port in which the MineSweeperServer will listen to.")
            .hasArg().withType(new Integer(0)).withArgName("PORT").withLongOpt("port").create(OPT_PORT));

    // parsing options
    //
    int port = DEFAULT_PORT;
    try {
        // using GNU standard
        //
        CommandLine line = new GnuParser().parse(options, args);

        if (line.hasOption(OPT_HELP)) {
            new HelpFormatter().printHelp("mss [options]", options);
            return;
        }

        if (line.hasOption(OPT_PORT)) {
            try {
                port = (Integer) line.getOptionObject(OPT_PORT);
            } catch (Exception e) {
            }
        }
    } catch (ParseException e) {
        System.err.println("Could not parse command line options correctly: " + e.getMessage());
        return;
    }

    //
    // configuring logging services
    //

    try {
        LogManager.getLogManager()
                .readConfiguration(ClassLoader.getSystemResourceAsStream(DEFAULT_LOGGING_CONFIG_FILE));
    } catch (Exception e) {
        throw new Error("Could not load logging properties file", e);
    }

    //
    // setting up UDP server
    //      

    try {
        new MSServer(port);
    } catch (Exception e) {
        LoggerFactory.getLogger(MSSMain.class).error("Could not execute MineSweeper server: ", e);
    }
}

From source file:com.bryan.gui.HotelBrokerApp.java

public static void main(String[] args) {
    try {/*from  ww w  .  j a va2 s  . c  om*/

        final HotelBrokerApp hotelBrokerApp = new HotelBrokerApp("Monash Hotel Broker");

        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                hotelBrokerApp.initView();
            }
        });

    } catch (Exception ex) {
        System.out.println("Failed to run application: " + ex.getMessage());
    }
}

From source file:fr.ens.transcriptome.teolenn.Main.java

/**
 * Main method./* w  ww .  jav  a2  s.c o  m*/
 * @param args command line arguments
 */
public static void main(final String[] args) throws IOException, DocumentException {

    // Set log level
    logger.setLevel(Globals.LOG_LEVEL);
    logger.getParent().getHandlers()[0].setFormatter(Globals.LOG_FORMATTER);

    // Parse the command line
    final int argsOptions = parseCommandLine(args);

    final File designFile = new File(args[argsOptions + 0]);
    final File genomeFile = args.length > argsOptions + 1 ? new File(args[argsOptions + 1]) : null;
    final File genomeMaskedFile = args.length > argsOptions + 2 ? new File(args[argsOptions + 2]) : null;
    final File outputDir = args.length > argsOptions + 3 ? new File(args[argsOptions + 3]) : null;

    try {

        final DesignReader designReader = new DesignReader();

        // Read design
        designReader.readDesign(designFile, genomeFile, genomeMaskedFile, outputDir);

        // Execute design
        designReader.getDesign().execute();

    } catch (Exception e) {
        System.err.println(e.getMessage());
        if (Globals.DEBUG)
            e.printStackTrace();
        System.exit(1);
    }

}

From source file:org.eclipse.lyo.client.oslc.samples.GenericCMSample.java

/**
 * Access a CM service provider and perform some OSLC actions
 * @param args/*from  w w  w. j  av a2s.  c o m*/
 * @throws ParseException 
 */
public static void main(String[] args) throws ParseException {

    Options options = new Options();

    options.addOption("url", true, "url"); //the OSLC catalog URL
    options.addOption("providerTitle", true, "Service Provider title");

    CommandLineParser cliParser = new GnuParser();

    //Parse the command line
    CommandLine cmd = cliParser.parse(options, args);

    if (!validateOptions(cmd)) {
        logger.severe(
                "Syntax:  java <class_name> -url https://<server>:port/<context>/<catalog_location> -providerTitle \"<provider title>\"");
        logger.severe(
                "Example: java GenericCMSample -url https://exmple.com:8080/OSLC4JRegistry/catalog/1 -providerTitle \"OSLC Lyo Change Management Service Provider\"");
        return;
    }

    String catalogUrl = cmd.getOptionValue("url");
    String providerTitle = cmd.getOptionValue("providerTitle");

    try {

        //STEP 1: Create a new generic OslcClient
        OslcClient client = new OslcClient();

        //STEP 2: Find the OSLC Service Provider for the project area we want to work with
        String serviceProviderUrl = client.lookupServiceProviderUrl(catalogUrl, providerTitle);

        //STEP 3: Get the Query Capabilities and Creation Factory URLs so that we can run some OSLC queries
        String queryCapability = client.lookupQueryCapability(serviceProviderUrl, OSLCConstants.OSLC_CM_V2,
                OSLCConstants.CM_CHANGE_REQUEST_TYPE);

        String creationFactory = client.lookupCreationFactory(serviceProviderUrl, OSLCConstants.OSLC_CM_V2,
                OSLCConstants.CM_CHANGE_REQUEST_TYPE);

        //SCENARIO A: Run a query for all ChangeRequests 

        OslcQueryParameters queryParams = new OslcQueryParameters();
        OslcQuery query = new OslcQuery(client, queryCapability);

        OslcQueryResult result = query.submit();

        boolean processAsJavaObjects = true;
        processPagedQueryResults(result, client, processAsJavaObjects);

        System.out.println("\n------------------------------\n");

        //SCENARIO B:  Run a query for a specific ChangeRequest and then print it as raw XML.  
        //Change the URL below to match a real ChangeRequest

        ClientResponse rawResponse = client.getResource(
                "http://localhost:8080/OSLC4JChangeManagement/changeRequests/1", OSLCConstants.CT_XML);
        processRawResponse(rawResponse);
        rawResponse.consumeContent();

        //SCENARIO C:  ChangeRequest creation and update
        ChangeRequest newChangeRequest = new ChangeRequest();
        newChangeRequest.setTitle("Update database schema");
        newChangeRequest.setTitle("Need to update the database schema to reflect the data model changes");

        rawResponse = client.createResource(creationFactory, newChangeRequest, OSLCConstants.CT_RDF);
        int statusCode = rawResponse.getStatusCode();
        rawResponse.consumeContent();
        System.out.println("Status code for POST of new artifact: " + statusCode);

        if (statusCode == HttpStatus.SC_CREATED) {
            String location = rawResponse.getHeaders().getFirst("Location");
            newChangeRequest.setClosed(false);
            newChangeRequest.setInProgress(true);
            rawResponse = client.updateResource(location, newChangeRequest, OSLCConstants.CT_RDF);
            rawResponse.consumeContent();
            System.out.println("Status code for PUT of updated artifact: " + rawResponse.getStatusCode());
        }

    } catch (Exception e) {
        logger.log(Level.SEVERE, e.getMessage(), e);
    }

}

From source file:org.fcrepo.client.Downloader.java

/**
 * Test this class.//  w  ww  .j a va2s .  c om
 */
public static void main(String[] args) {
    try {
        if (args.length == 8 || args.length == 9) {
            String host = args[0];
            int port = Integer.parseInt(args[1]);
            String user = args[2];
            String password = args[3];
            String pid = args[4];
            String dsid = args[5];
            File outfile = new File(args[6]);
            String asOfDateTime = args.length == 8 ? args[7] : null;
            String context = args.length == 9 ? args[8] : null;

            FileOutputStream outStream = new FileOutputStream(outfile);
            Downloader downloader = new Downloader(host, port, context, user, password);

            downloader.getDatastreamContent(pid, dsid, asOfDateTime, outStream);
        } else {
            System.err.println(
                    "Usage: Downloader host port user password pid dsid outfile [MMDDYYTHH:MM:SS] [context]");
        }
    } catch (Exception e) {
        e.printStackTrace();
        System.err.println("ERROR: " + e.getMessage());
    }
}