List of usage examples for java.lang Throwable printStackTrace
public void printStackTrace()
From source file:caarray.client.examples.grid.DownloadDataColumnsFromFile.java
public static void main(String[] args) { DownloadDataColumnsFromFile downloader = new DownloadDataColumnsFromFile(); try {/*from w w w . j ava2s .c o m*/ client = new CaArraySvc_v1_0Client(BaseProperties.getGridServiceUrl()); searchServiceHelper = new GridSearchApiUtils(client); System.out .println("Downloading data columns from a file in the experiment " + EXPERIMENT_TITLE + "..."); downloader.download(); } catch (Throwable t) { System.out.println("Error while downloading data columns from a file."); t.printStackTrace(); } }
From source file:caarray.client.test.full.LoadTest.java
/** * @param args/* ww w . j a v a 2 s . c o m*/ */ public static void main(String[] args) { List<ApiFacade> apiFacades = new ArrayList<ApiFacade>(); List<List<ConfigurableTestSuite>> testSuiteCollection = new ArrayList<List<ConfigurableTestSuite>>(); int numThreads = TestProperties.getNumThreads(); if (numThreads <= 1) { System.out.println( "Thread count for load test set to 1 - setting to default count of " + DEFAULT_THREADS); numThreads = DEFAULT_THREADS; } try { for (int i = apiFacades.size(); i < numThreads; i++) { apiFacades.add(new FullApiFacade()); } for (int i = testSuiteCollection.size(); i < numThreads; i++) { List<ConfigurableTestSuite> shortTests = TestMain.getShortTestSuites(apiFacades.get(i)); List<ConfigurableTestSuite> longTests = TestMain.getLongTestSuites(apiFacades.get(i)); List<ConfigurableTestSuite> testSuites = new ArrayList<ConfigurableTestSuite>(); testSuites.addAll(shortTests); testSuites.addAll(longTests); testSuiteCollection.add(testSuites); } TestResultReport[] threadReports = new TestResultReport[numThreads]; for (int i = 0; i < numThreads; i++) { threadReports[i] = new TestResultReport(); } Thread[] loadTestThreads = new Thread[numThreads]; for (int i = 0; i < numThreads; i++) { LoadTestThread thread = new LoadTestThread(apiFacades.get(i), testSuiteCollection.get(i), threadReports[i], i); loadTestThreads[i] = new Thread(thread); } System.out.println("Executing load tests for " + numThreads + " threads ..."); long start = System.currentTimeMillis(); for (int i = 0; i < numThreads; i++) { loadTestThreads[i].start(); } for (int i = 0; i < numThreads; i++) { loadTestThreads[i].join(); } long time = System.currentTimeMillis() - start; System.out.println("Load tests completed in " + (double) time / (double) 1000 + " seconds."); TestResultReport finalReport = new TestResultReport(); for (TestResultReport report : threadReports) { finalReport.merge(report); } System.out.println("Analyzing load test results ..."); finalReport.writeLoadTestReports(); } catch (Throwable t) { System.out.println("An exception occured execuitng the load tests: " + t.getClass()); System.out.println("Test suite aborted."); t.printStackTrace(); log.error("Exception encountered:", t); } }
From source file:esg.node.connection.ESGConnectorTester.java
public static void main(String[] args) { for (String arg : args) System.out.println(arg);/* w w w.j a va2 s . co m*/ if (args.length < 1 || args.length > 2) { System.out.println(" Usage requries args: [\"prune\" | \"ping\"]"); System.exit(1); } System.out.println("Running ESGConnector..."); String function = args[0]; String host = "localhost"; if (args.length == 2) host = args[1]; try { if (function.equalsIgnoreCase("prune")) { System.out.println("prune -> " + host); if (ESGConnector.getInstance().setSecured(false).setEndpoint(host, true).prune()) { System.out.println("Pruned dead peer connections from " + host); } else { System.out.println("There were no dead peer connections detected on " + host + " (or host itself is dead)"); } } if (function.equalsIgnoreCase("ping")) { System.out.println("ping -> " + host); if (ESGConnector.getInstance().setSecured(false).setEndpoint(host, true).ping()) { System.out.println("Successfully pinged " + host); } else { System.out.println("Unable to ping " + host); } } } catch (Throwable t) { log.error("Oops there was a problem... is the node manager running on " + ESGConnector.getInstance().getEndpoint() + "?"); log.error(t); t.printStackTrace(); ESGConnector.getInstance().clearCache(); } System.out.println("bye"); }
From source file:org.openvpms.report.tools.ReportTool.java
/** * Main line.//ww w . ja va 2 s . co m * * @param args command line arguments */ public static void main(String[] args) { try { JSAP parser = createParser(); JSAPResult config = parser.parse(args); if (!config.success()) { displayUsage(parser); } else { String contextPath = config.getString("context"); boolean list = config.getBoolean("list"); boolean report = config.getBoolean("report"); String shortName = config.getString("shortName"); long id = config.getLong("id", -1); String name = config.getString("name"); String output = config.getString("output"); if (list && shortName != null) { ReportTool reporter = new ReportTool(contextPath); reporter.list(shortName); } else if (report && shortName != null && output != null) { ReportTool reporter = new ReportTool(contextPath); IMObject object; if (id == -1) { object = reporter.get(shortName, name); } else { object = reporter.get(shortName, id); } if (object != null) { reporter.save(object, output); } else { System.out.println("No match found"); } } else { displayUsage(parser); } } } catch (Throwable throwable) { throwable.printStackTrace(); System.exit(1); } System.exit(0); }
From source file:caarray.client.examples.java.DownloadDataColumnsFromFile.java
public static void main(String[] args) { DownloadDataColumnsFromFile downloader = new DownloadDataColumnsFromFile(); try {//from w ww .j a v a 2 s.co m CaArrayServer server = new CaArrayServer(BaseProperties.getServerHostname(), BaseProperties.getServerJndiPort()); server.connect(); searchService = server.getSearchService(); dataService = server.getDataService(); searchServiceHelper = new JavaSearchApiUtils(searchService); System.out .println("Downloading data columns from a file in the experiment " + EXPERIMENT_TITLE + "..."); downloader.download(); } catch (Throwable t) { System.out.println("Error while downloading data columns from a file."); t.printStackTrace(); } }
From source file:com.bazaarvoice.jsonpps.PrettyPrintJson.java
public static void main(String[] args) throws Exception { try {//ww w .j av a2 s . c o m ArgumentParser parser = ArgumentParsers.newArgumentParser("jsonpps") .description("A streaming JSON pretty printer that can format multi-GB input files.") .defaultHelp(true); parser.addArgument("-o", "--out").type(Arguments.fileType()).setDefault(STDINOUT).help("output file"); parser.addArgument("--flatten").metavar("N").type(Integer.class).setDefault(0) .help("flatten the top-N levels of object/array structure"); parser.addArgument("-i", "--in-place").action(Arguments.storeTrue()) .help("modify the original file(s)"); parser.addArgument("-S", "--sort-keys").action(Arguments.storeTrue()).help( "emit objects with keys in sorted order. this increases memory requirements since objects must be buffered in memory."); parser.addArgument("--strict").action(Arguments.storeTrue()).help("reject non-conforming json"); parser.addArgument("--wrap").action(Arguments.storeTrue()).help("wrap all output in a json array"); parser.addArgument("--unwrap").action(Arguments.storeTrue()) .help("flatten the top level of object/array structure"); parser.addArgument("in").nargs("*") .type(Arguments.fileType().acceptSystemIn().verifyExists().verifyIsFile().verifyCanRead()) .setDefault(new File[] { STDINOUT }).help("input file(s)"); Namespace ns; try { ns = parser.parseArgs(args); } catch (ArgumentParserException e) { parser.handleError(e); System.exit(2); return; } PrettyPrintJson jsonpp = new PrettyPrintJson(); File outputFile = ns.get("out"); List<File> inputFiles = ns.getList("in"); boolean inPlace = ns.getBoolean("in_place"); jsonpp.setFlatten(ns.getInt("flatten")); jsonpp.setSortKeys(ns.getBoolean("sort_keys")); jsonpp.setStrict(ns.getBoolean("strict")); jsonpp.setWrap(ns.getBoolean("wrap")); if (ns.getBoolean("unwrap")) { jsonpp.setFlatten(1); } if (!inPlace) { // Pretty print all input files to a single output jsonpp.prettyPrint(inputFiles, outputFile); } else { // Pretty print all input files back to themselves. if (outputFile != STDINOUT) { // use "!=" not "!.equals()" since default is ok but "-o -" is not. System.err.println("error: -o and --in-place are mutually exclusive"); System.exit(2); } if (inputFiles.isEmpty()) { System.err.println("error: --in-place requires at least one input file"); System.exit(2); } if (inputFiles.contains(STDINOUT)) { System.err.println("error: --in-place cannot operate on stdin"); System.exit(2); } for (File inputFile : inputFiles) { jsonpp.prettyPrint(inputFile, inputFile); } } } catch (Throwable t) { t.printStackTrace(); System.err.println(t.toString()); System.exit(1); } }
From source file:com.opendoorlogistics.core.geometry.ImportShapefile.java
public static void main(String[] args) { for (String filename : new String[] { "C:\\Processing\\all\\districts.shp", "C:\\Processing\\all\\districts2.shp", "districts2.shp", "dir2\\dir3\\districts2.shp" }) { ShapefileLink link = new ShapefileLink(filename, "", ""); try {/* w w w .ja v a2 s . co m*/ File validated = RelativeFiles.validateRelativeFiles(link.getFile(), AppConstants.SHAPEFILES_DIRECTORY); String saveAs = RelativeFiles.getFilenameToSaveInLink(validated, AppConstants.SHAPEFILES_DIRECTORY); System.out.println("Load from: " + validated + " Save as:" + saveAs); } catch (Throwable e) { e.printStackTrace(); } } // // C:\Users\Phil\Dropbox\Business\Data\Shapefiles\Antartica\natural.shp // String filename = "C:\\Processing\\all\\districts.shp"; // // System.out.println("Starting1 " + new Date()); // importShapefile(new File(filename),false); // System.out.println("Finished1 " + new Date()); // // System.out.println("Starting2 " + new Date()); // for(int i =0 ;i <2767 ; i++){ // ShapefileLink link = new ShapefileLink(filename, "districts", "districts." + i); // Object geometry = Spatial.loadLink(link); // //System.out.println(link + "->" + (geometry==null? "Not loaded" : "Loaded")); // } // System.out.println("Finishing2 " + new Date()); // // System.out.println("Starting3 " + new Date()); // importShapefile(new File(filename),false); // System.out.println("Finished3 " + new Date()); }
From source file:catalina.startup.BootstrapService.java
/** * Main method, used for testing only.//from w ww . ja v a 2 s . c o m * * @param args Command line arguments to be processed */ public static void main(String args[]) { // Set the debug flag appropriately for (int i = 0; i < args.length; i++) { if ("-debug".equals(args[i])) debug = 1; } if (service == null) { service = new BootstrapService(); try { BootstrapServiceContext p0 = new BootstrapServiceContext(); p0.setArguments(args); service.init(p0); } catch (Throwable t) { t.printStackTrace(); return; } } try { String command = args[0]; if (command.equals("start")) { service.start(); } else if (command.equals("stop")) { service.stop(); } } catch (Throwable t) { t.printStackTrace(); } }
From source file:it.cnr.icar.eric.client.xml.registry.infomodel.RegistryPackageTest.java
public static void main(String[] args) { try {/* w ww. j a va2s.co m*/ TestRunner.run(suite()); } catch (Throwable t) { System.out.println("Throwable: " + t.getClass().getName() + " Message: " + t.getMessage()); t.printStackTrace(); } }
From source file:kellinwood.zipsigner.cmdline.Main.java
public static void main(String[] args) { try {//ww w . ja v a 2s . co m Options options = new Options(); CommandLine cmdLine = null; Option helpOption = new Option("h", "help", false, "Display usage information"); Option modeOption = new Option("m", "keymode", false, "Keymode one of: auto, auto-testkey, auto-none, media, platform, shared, testkey, none"); modeOption.setArgs(1); Option keyOption = new Option("k", "key", false, "PCKS#8 encoded private key file"); keyOption.setArgs(1); Option pwOption = new Option("p", "keypass", false, "Private key password"); pwOption.setArgs(1); Option certOption = new Option("c", "cert", false, "X.509 public key certificate file"); certOption.setArgs(1); Option sbtOption = new Option("t", "template", false, "Signature block template file"); sbtOption.setArgs(1); Option keystoreOption = new Option("s", "keystore", false, "Keystore file"); keystoreOption.setArgs(1); Option aliasOption = new Option("a", "alias", false, "Alias for key/cert in the keystore"); aliasOption.setArgs(1); options.addOption(helpOption); options.addOption(modeOption); options.addOption(keyOption); options.addOption(certOption); options.addOption(sbtOption); options.addOption(pwOption); options.addOption(keystoreOption); options.addOption(aliasOption); Parser parser = new BasicParser(); try { cmdLine = parser.parse(options, args); } catch (MissingOptionException x) { System.out.println("One or more required options are missing: " + x.getMessage()); usage(options); } catch (ParseException x) { System.out.println(x.getClass().getName() + ": " + x.getMessage()); usage(options); } if (cmdLine.hasOption(helpOption.getOpt())) usage(options); Properties log4jProperties = new Properties(); log4jProperties.load(new FileReader("log4j.properties")); PropertyConfigurator.configure(log4jProperties); LoggerManager.setLoggerFactory(new Log4jLoggerFactory()); List<String> argList = cmdLine.getArgList(); if (argList.size() != 2) usage(options); ZipSigner signer = new ZipSigner(); signer.addAutoKeyObserver(new Observer() { @Override public void update(Observable observable, Object o) { System.out.println("Signing with key: " + o); } }); Class bcProviderClass = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider"); Provider bcProvider = (Provider) bcProviderClass.newInstance(); KeyStoreFileManager.setProvider(bcProvider); signer.loadProvider("org.spongycastle.jce.provider.BouncyCastleProvider"); PrivateKey privateKey = null; if (cmdLine.hasOption(keyOption.getOpt())) { if (!cmdLine.hasOption(certOption.getOpt())) { System.out.println("Certificate file is required when specifying a private key"); usage(options); } String keypw = null; if (cmdLine.hasOption(pwOption.getOpt())) keypw = pwOption.getValue(); else { keypw = new String(readPassword("Key password")); if (keypw.equals("")) keypw = null; } URL privateKeyUrl = new File(keyOption.getValue()).toURI().toURL(); privateKey = signer.readPrivateKey(privateKeyUrl, keypw); } X509Certificate cert = null; if (cmdLine.hasOption(certOption.getOpt())) { if (!cmdLine.hasOption(keyOption.getOpt())) { System.out.println("Private key file is required when specifying a certificate"); usage(options); } URL certUrl = new File(certOption.getValue()).toURI().toURL(); cert = signer.readPublicKey(certUrl); } byte[] sigBlockTemplate = null; if (cmdLine.hasOption(sbtOption.getOpt())) { URL sbtUrl = new File(sbtOption.getValue()).toURI().toURL(); sigBlockTemplate = signer.readContentAsBytes(sbtUrl); } if (cmdLine.hasOption(keyOption.getOpt())) { signer.setKeys("custom", cert, privateKey, sigBlockTemplate); signer.signZip(argList.get(0), argList.get(1)); } else if (cmdLine.hasOption(modeOption.getOpt())) { signer.setKeymode(modeOption.getValue()); signer.signZip(argList.get(0), argList.get(1)); } else if (cmdLine.hasOption((keystoreOption.getOpt()))) { String alias = null; if (!cmdLine.hasOption(aliasOption.getOpt())) { KeyStore keyStore = KeyStoreFileManager.loadKeyStore(keystoreOption.getValue(), (char[]) null); for (Enumeration<String> e = keyStore.aliases(); e.hasMoreElements();) { alias = e.nextElement(); System.out.println("Signing with key: " + alias); break; } } else alias = aliasOption.getValue(); String keypw = null; if (cmdLine.hasOption(pwOption.getOpt())) keypw = pwOption.getValue(); else { keypw = new String(readPassword("Key password")); if (keypw.equals("")) keypw = null; } CustomKeySigner.signZip(signer, keystoreOption.getValue(), null, alias, keypw.toCharArray(), "SHA1withRSA", argList.get(0), argList.get(1)); } else { signer.setKeymode("auto-testkey"); signer.signZip(argList.get(0), argList.get(1)); } } catch (Throwable t) { t.printStackTrace(); } }