List of usage examples for java.lang RuntimeException printStackTrace
public void printStackTrace()
From source file:ConfigTest.java
/** * Start test of the client.//from w ww. j a va2s . c om * * @param args * no args expected. */ public static void main(final String[] args) { try { new ConfigTest().run(); } catch (RuntimeException e) { e.printStackTrace(); } }
From source file:edu.pitt.sis.infsci2730.finalProject.dao.ZZTest.java
public static void main(String[] args) throws Exception { try {/*from ww w . j av a 2 s . c o m*/ ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml"); AddressDao dao = (AddressDao) ac.getBean("addressDao"); String[] a = { "Pittsburgh", "Fifth", "PA", "15213" }; // String[] b={"2","2","3","15"}; System.out.println(dao.addAddress(a)); // System.out.println(dao.InsertRecordByTransactionIDAndProductId(b)); // List<RecordDBModel> list=dao.GetRecordByTransactionID("1"); // for(RecordDBModel r:list){ // System.out.println("GetRecordByTransactionID "+r.getProduct_id()); // } // // List<RecordDBModel> list2=dao.GetRecordByProductID("1"); // for(RecordDBModel r:list2){ // System.out.println("GetRecordByProductID "+r.getProduct_id()); // } // System.out.println("GetTransaction"); // SqlRowSet rows = dao.GetTransaction("5"); // while(rows.next()){ // System.out.println(rows.getInt(1)+" "+rows.getTimestamp(2)+" "+rows.getInt(4)); // } } catch (RuntimeException e) { e.printStackTrace(); } }
From source file:com.samples.platform.client.test.ClientTest.java
/** * Start test of the client.//w ww. jav a 2s . co m * * @param args * no args expected. */ public static void main(final String[] args) { try { new ClientTest().run(); } catch (RuntimeException e) { e.printStackTrace(); } }
From source file:de.softwareforge.pgpsigner.PGPSigner.java
public static void main(final String[] args) { Security.addProvider(new BouncyCastleProvider()); /*//ww w . ja va 2 s.co m * Debug Code. Add a Security Manager and a policy. * Suggested by Simon Tuffs, unfortunately does not really help * the one-jar problem. if (System.getSecurityManager() == null) { String policy = System.getProperty("java.security.policy"); if (policy == null) { System.setProperty("java.security.policy", "onejar:/pgpsigner.policy"); } System.setSecurityManager(new SecurityManager()); } */ /* * DEBUG: Display all registered Security providers * Provider[] providers = Security.getProviders(); for (int i=0; i < providers.length; i++) { System.out.println(providers[i].toString()); } */ PGPSigner pgpSigner = new PGPSigner(args); try { pgpSigner.run(); } catch (RuntimeException re) { re.printStackTrace(); throw re; } catch (Exception e) { e.printStackTrace(); } System.exit(0); }
From source file:org.azyva.dragom.tool.GenericModelVisitorJobInvokerTool.java
/** * Method main.//from w ww . j a va2 s . com * * @param args Arguments. */ public static void main(String[] args) { String modelVisitorJobClass; String helpResource; DefaultParser defaultParser; CommandLine commandLine = null; Constructor<? extends ModelVisitorJob> constructor; ModelVisitorJob modelVisitorJob; int exitStatus; modelVisitorJobClass = args[0]; helpResource = args[1]; args = Arrays.copyOfRange(args, 2, args.length); GenericModelVisitorJobInvokerTool.init(); modelVisitorJob = null; try { defaultParser = new DefaultParser(); try { commandLine = defaultParser.parse(GenericModelVisitorJobInvokerTool.options, args); } catch (ParseException pe) { throw new RuntimeExceptionUserError(MessageFormat.format( CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_ERROR_PARSING_COMMAND_LINE), pe.getMessage(), CliUtil.getHelpCommandLineOption())); } if (CliUtil.hasHelpOption(commandLine)) { GenericModelVisitorJobInvokerTool.help(helpResource); } else { List<NodePath> listNodePathBase; args = commandLine.getArgs(); CliUtil.setupExecContext(commandLine, true); if (args.length != 0) { listNodePathBase = new ArrayList<>(); for (String arg : args) { try { listNodePathBase.add(NodePath.parse(arg)); } catch (java.text.ParseException pe) { throw new RuntimeExceptionUserError(MessageFormat.format( CliUtil.getLocalizedMsgPattern( CliUtil.MSG_PATTERN_KEY_ERROR_PARSING_COMMAND_LINE), pe.getMessage(), CliUtil.getHelpCommandLineOption())); } } } else { listNodePathBase = null; } try { constructor = Class.forName(modelVisitorJobClass).asSubclass(ModelVisitorJob.class) .getConstructor(List.class); modelVisitorJob = constructor.newInstance(listNodePathBase); } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e) { throw new RuntimeException(e); } modelVisitorJob.performJob(); } // Need to call before ExecContextHolder.endToolAndUnset. exitStatus = Util.getExitStatusAndShowReason(); } catch (RuntimeExceptionUserError reue) { System.err.println( CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_USER_ERROR_PREFIX) + reue.getMessage()); exitStatus = 1; } catch (RuntimeException re) { re.printStackTrace(); exitStatus = 1; } finally { ExecContextHolder.endToolAndUnset(); } System.exit(exitStatus); }
From source file:org.azyva.dragom.tool.GenericRootModuleVersionJobInvokerTool.java
/** * Method main.//from w ww .j a v a2 s .c o m * * @param args Arguments. */ public static void main(String[] args) { String rootModuleVersionJobClass; String helpResource; DefaultParser defaultParser; CommandLine commandLine = null; Constructor<? extends RootModuleVersionJob> constructor; RootModuleVersionJob rootModuleVersionJob; int exitStatus; rootModuleVersionJobClass = args[0]; helpResource = args[1]; args = Arrays.copyOfRange(args, 2, args.length); GenericRootModuleVersionJobInvokerTool.init(); rootModuleVersionJob = null; try { defaultParser = new DefaultParser(); try { commandLine = defaultParser.parse(GenericRootModuleVersionJobInvokerTool.options, args); } catch (ParseException pe) { throw new RuntimeExceptionUserError(MessageFormat.format( CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_ERROR_PARSING_COMMAND_LINE), pe.getMessage(), CliUtil.getHelpCommandLineOption())); } if (CliUtil.hasHelpOption(commandLine)) { GenericRootModuleVersionJobInvokerTool.help(helpResource); } else { args = commandLine.getArgs(); if (args.length != 0) { throw new RuntimeExceptionUserError(MessageFormat.format( CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_INVALID_ARGUMENT_COUNT), CliUtil.getHelpCommandLineOption())); } CliUtil.setupExecContext(commandLine, true); try { constructor = Class.forName(rootModuleVersionJobClass).asSubclass(RootModuleVersionJob.class) .getConstructor(List.class); rootModuleVersionJob = constructor.newInstance(CliUtil.getListModuleVersionRoot(commandLine)); } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e) { throw new RuntimeException(e); } rootModuleVersionJob.setReferencePathMatcherProvided(CliUtil.getReferencePathMatcher(commandLine)); if (rootModuleVersionJob instanceof ConfigHandleStaticVersion) { if (commandLine.hasOption("no-handle-static-version")) { ((ConfigHandleStaticVersion) rootModuleVersionJob).setIndHandleStaticVersion(false); } } if (rootModuleVersionJob instanceof ConfigReentryAvoider) { if (commandLine.hasOption("no-avoid-reentry")) { ((ConfigReentryAvoider) rootModuleVersionJob).setIndAvoidReentry(false); } } rootModuleVersionJob.performJob(); } // Need to call before ExecContextHolder.endToolAndUnset. exitStatus = Util.getExitStatusAndShowReason(); } catch (RuntimeExceptionUserError reue) { System.err.println( CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_USER_ERROR_PREFIX) + reue.getMessage()); exitStatus = 1; } catch (RuntimeException re) { re.printStackTrace(); exitStatus = 1; } finally { if ((rootModuleVersionJob != null) && rootModuleVersionJob.isListModuleVersionRootChanged()) { // It can be the case that RootManager does not specify any root ModuleVersion. In // that case calling RootManager.saveListModuleVersion simply saves an empty list, // even if the user has specified a root ModuleVersion on the command line. RootManager.saveListModuleVersion(); } ExecContextHolder.endToolAndUnset(); } System.exit(exitStatus); }
From source file:org.azyva.dragom.tool.SetupJenkinsJobsTool.java
/** * Method main.//from w w w .ja v a2s. co m * * @param args Arguments. */ public static void main(String[] args) { DefaultParser defaultParser; CommandLine commandLine = null; Path pathItemsCreatedFile; boolean indEmptyPathItemsCreatedFile; SetupJenkinsJobs.ItemsCreatedFileMode itemsCreatredFileMode; SetupJenkinsJobs setupJenkinsJobs; int exitStatus; SetupJenkinsJobsTool.init(); try { defaultParser = new DefaultParser(); try { commandLine = defaultParser.parse(SetupJenkinsJobsTool.options, args); } catch (ParseException pe) { throw new RuntimeExceptionUserError(MessageFormat.format( CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_ERROR_PARSING_COMMAND_LINE), pe.getMessage(), CliUtil.getHelpCommandLineOption())); } if (CliUtil.hasHelpOption(commandLine)) { SetupJenkinsJobsTool.help(); } else { args = commandLine.getArgs(); if (args.length != 0) { throw new RuntimeExceptionUserError(MessageFormat.format( CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_INVALID_ARGUMENT_COUNT), CliUtil.getHelpCommandLineOption())); } indEmptyPathItemsCreatedFile = false; if (commandLine.hasOption("items-created-file")) { String itemsCreatedFileOptionValue; itemsCreatedFileOptionValue = commandLine.getOptionValue("items-created-file"); if ((itemsCreatedFileOptionValue == null) || (itemsCreatedFileOptionValue.length() == 0)) { indEmptyPathItemsCreatedFile = true; pathItemsCreatedFile = null; } else { pathItemsCreatedFile = Paths.get(itemsCreatedFileOptionValue); } } else { pathItemsCreatedFile = null; } if (!commandLine.hasOption("items-created-file-mode")) { itemsCreatredFileMode = SetupJenkinsJobs.ItemsCreatedFileMode.MERGE; } else { try { itemsCreatredFileMode = SetupJenkinsJobs.ItemsCreatedFileMode .valueOf(commandLine.getOptionValue("items-created-file-mode")); } catch (IllegalArgumentException iae) { throw new RuntimeExceptionUserError(MessageFormat.format( CliUtil.getLocalizedMsgPattern( CliUtil.MSG_PATTERN_KEY_ERROR_PARSING_COMMAND_LINE_OPTION), "items-created-file-mode", SetupJenkinsJobsTool.resourceBundle.getString( SetupJenkinsJobsTool.MSG_PATTERN_KEY_ITEMS_CREATED_FILE_MODE_POSSIBLE_VALUES), CliUtil.getHelpCommandLineOption())); } } CliUtil.setupExecContext(commandLine, true); setupJenkinsJobs = new SetupJenkinsJobs(CliUtil.getListModuleVersionRoot(commandLine)); setupJenkinsJobs.setReferencePathMatcherProvided(CliUtil.getReferencePathMatcher(commandLine)); if (indEmptyPathItemsCreatedFile) { setupJenkinsJobs.setPathItemsCreatedFile(null); } else if (pathItemsCreatedFile != null) { setupJenkinsJobs.setPathItemsCreatedFile(pathItemsCreatedFile); } setupJenkinsJobs.setItemsCreatedFileMode(itemsCreatredFileMode); setupJenkinsJobs.performJob(); } // Need to call before ExecContextHolder.endToolAndUnset. exitStatus = Util.getExitStatusAndShowReason(); } catch (RuntimeExceptionUserError reue) { System.err.println( CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_USER_ERROR_PREFIX) + reue.getMessage()); exitStatus = 1; } catch (RuntimeException re) { re.printStackTrace(); exitStatus = 1; } finally { ExecContextHolder.endToolAndUnset(); } System.exit(exitStatus); }
From source file:wsattacker.plugin.intelligentdos.main.Main.java
public static void main(String[] args) { if (args.length > 100) { commandLineParser(args);//w ww .ja va2s .c o m } // reads the file name as first parameter // Signed_Request.xml fileName = args[0]; initLoggers(); long start = System.currentTimeMillis(); System.out.println("stat at " + new java.util.Date()); try { CurrentRequest original = create(); SchemaAnalyzer schemaAnalyzer = SchemaAnalyzerFactory.getInstance(SchemaAnalyzerFactory.WEBSERVICE); String xmlMessage = original.getWsdlRequest().getRequestContent(); PositionIterator positionIterator = new SchemaAnalyzerPositionIterator(schemaAnalyzer, xmlMessage); IntelligentDoSLibraryImpl intelligentDoSLibraryImpl = new IntelligentDoSLibraryImpl(xmlMessage, positionIterator); intelligentDoSLibraryImpl.setAttacks(new DoSAttack[] { new XmlEntityExpansion() }); intelligentDoSLibraryImpl.setSuccessDecider(new SimpleSuccessDecider()); // intelligentDoSLibraryImpl.setCommonParams( commonParamList ); intelligentDoSLibraryImpl.setServerRecoveryTime(20000); intelligentDoSLibraryImpl.initialize(); IntelligentDoSWorker doSWorker = new IntelligentDoSWorker(intelligentDoSLibraryImpl); doSWorker.addListener(new AttackModelChangeListener() { private int count = 0; @Override public void attackModelChanged(AttackModel attackModel) { System.out.println(++count + "\t: " + attackModel); } }); doSWorker.startAttack(original); long stop = System.currentTimeMillis(); System.out.println( "count: " + doSWorker.getCount() + " at " + new java.util.Date() + " -> " + (stop - start)); } catch (RuntimeException e) { throw e; } catch (Exception e) { e.printStackTrace(); } System.exit(0); }
From source file:org.azyva.dragom.tool.ReferenceGraphReportTool.java
/** * Method main./*from w ww .j a va 2s. c o m*/ * * @param args Arguments. */ public static void main(String[] args) { DefaultParser defaultParser; CommandLine commandLine = null; ReferenceGraphReport referenceGraphReport; ReferenceGraphReport.OutputFormat outputFormat; int exitStatus; ReferenceGraphReportTool.init(); try { defaultParser = new DefaultParser(); try { commandLine = defaultParser.parse(ReferenceGraphReportTool.options, args); } catch (ParseException pe) { throw new RuntimeExceptionUserError(MessageFormat.format( CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_ERROR_PARSING_COMMAND_LINE), pe.getMessage(), CliUtil.getHelpCommandLineOption())); } if (CliUtil.hasHelpOption(commandLine)) { ReferenceGraphReportTool.help(); } else { args = commandLine.getArgs(); if (args.length != 1) { throw new RuntimeExceptionUserError(MessageFormat.format( CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_INVALID_ARGUMENT_COUNT), CliUtil.getHelpCommandLineOption())); } CliUtil.setupExecContext(commandLine, true); if (!commandLine.hasOption("output-format")) { outputFormat = ReferenceGraphReport.OutputFormat.TEXT; } else { try { outputFormat = ReferenceGraphReport.OutputFormat .valueOf(commandLine.getOptionValue("output-format")); } catch (IllegalArgumentException iae) { throw new RuntimeExceptionUserError(MessageFormat.format(CliUtil .getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_ERROR_PARSING_COMMAND_LINE_OPTION), "output-format", ReferenceGraphReportTool.resourceBundle.getString( ReferenceGraphReportTool.MSG_PATTERN_KEY_OUTPUT_FORMAT_POSSIBLE_VALUES), CliUtil.getHelpCommandLineOption())); } } if (!commandLine.hasOption("graph") && !commandLine.hasOption("module-versions")) { throw new RuntimeExceptionUserError(MessageFormat.format( ReferenceGraphReportTool.resourceBundle.getString( ReferenceGraphReportTool.MSG_PATTERN_KEY_GRAPH_OR_MODULE_VERSION_REQUIRED), CliUtil.getHelpCommandLineOption())); } if (commandLine.hasOption("avoid-redundancy") && !commandLine.hasOption("graph")) { throw new RuntimeExceptionUserError(MessageFormat.format( ReferenceGraphReportTool.resourceBundle .getString(ReferenceGraphReportTool.MSG_PATTERN_KEY_GRAPH_REQUIRED_WHEN), CliUtil.getHelpCommandLineOption())); } if ((commandLine.hasOption("only-multiple-versions") || commandLine.hasOption("only-matched-modules") || commandLine.hasOption("most-recent-version-in-reference-graph") || commandLine.hasOption("most-recent-static-version-in-scm") || commandLine.hasOption("reference-paths")) && !commandLine.hasOption("module-versions")) { throw new RuntimeExceptionUserError(MessageFormat.format( ReferenceGraphReportTool.resourceBundle.getString( ReferenceGraphReportTool.MSG_PATTERN_KEY_MODULE_VERSIONS_REQUIRED_WHEN), CliUtil.getHelpCommandLineOption())); } if (commandLine.hasOption("only-multiple-versions") && commandLine.hasOption("only-matched-modules")) { throw new RuntimeExceptionUserError(MessageFormat.format( ReferenceGraphReportTool.resourceBundle.getString( ReferenceGraphReportTool.MSG_PATTERN_KEY_ONLY_MULTIPLE_VERSIONS_AND_ONLY_MATCHED_MODULES_MUTUALLY_EXCLUSIVE), CliUtil.getHelpCommandLineOption())); } referenceGraphReport = new ReferenceGraphReport(CliUtil.getListModuleVersionRoot(commandLine), outputFormat); referenceGraphReport.setReferencePathMatcherProvided(CliUtil.getReferencePathMatcher(commandLine)); referenceGraphReport.setOutputFilePath(Paths.get(args[0])); if (commandLine.hasOption("graph")) { ReferenceGraphReport.ReferenceGraphMode referenceGraphMode; if (commandLine.hasOption("avoid-redundancy")) { referenceGraphMode = ReferenceGraphReport.ReferenceGraphMode.TREE_NO_REDUNDANCY; } else { referenceGraphMode = ReferenceGraphReport.ReferenceGraphMode.FULL_TREE; } referenceGraphReport.includeReferenceGraph(referenceGraphMode); } if (commandLine.hasOption("module-versions")) { ReferenceGraphReport.ModuleFilter moduleFilter; if (commandLine.hasOption("only-multiple-versions")) { moduleFilter = ReferenceGraphReport.ModuleFilter.ONLY_MULTIPLE_VERSIONS; } else if (commandLine.hasOption("only-matched-modules")) { moduleFilter = ReferenceGraphReport.ModuleFilter.ONLY_MATCHED; } else { moduleFilter = ReferenceGraphReport.ModuleFilter.ALL; } referenceGraphReport.includeModules(moduleFilter); } if (commandLine.hasOption("most-recent-version-in-reference-graph")) { referenceGraphReport.includeMostRecentVersionInReferenceGraph(); } if (commandLine.hasOption("most-recent-static-version-in-scm")) { referenceGraphReport.includeMostRecentStaticVersionInScm(); } if (commandLine.hasOption("reference-paths")) { referenceGraphReport.includeReferencePaths(); } referenceGraphReport.performJob(); } // Need to call before ExecContextHolder.endToolAndUnset. exitStatus = Util.getExitStatusAndShowReason(); } catch (RuntimeExceptionUserError reue) { System.err.println( CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_USER_ERROR_PREFIX) + reue.getMessage()); exitStatus = 1; } catch (RuntimeException re) { re.printStackTrace(); exitStatus = 1; } finally { ExecContextHolder.endToolAndUnset(); } System.exit(exitStatus); }
From source file:test1.ApacheHttpRestClient2.java
public final static void main(String[] args) { HttpClient httpClient = new DefaultHttpClient(); try {// w w w . j a v a2 s. co m // this ona api call returns results in a JSON format HttpGet httpGetRequest = new HttpGet("https://api.ona.io/api/v1/users"); // Execute HTTP request HttpResponse httpResponse = httpClient.execute(httpGetRequest); System.out.println("------------------HTTP RESPONSE----------------------"); System.out.println(httpResponse.getStatusLine()); System.out.println("------------------HTTP RESPONSE----------------------"); // Get hold of the response entity HttpEntity entity = httpResponse.getEntity(); // If the response does not enclose an entity, there is no need // to bother about connection release byte[] buffer = new byte[1024]; if (entity != null) { InputStream inputStream = entity.getContent(); try { int bytesRead = 0; BufferedInputStream bis = new BufferedInputStream(inputStream); while ((bytesRead = bis.read(buffer)) != -1) { String chunk = new String(buffer, 0, bytesRead); FileWriter file = new FileWriter("C:\\Users\\fred\\Desktop\\webicons\\output.txt"); //file.write(chunk.toJSONString()); file.write(chunk.toCharArray()); file.flush(); file.close(); System.out.print(chunk); System.out.println(chunk); } } catch (IOException ioException) { // In case of an IOException the connection will be released // back to the connection manager automatically ioException.printStackTrace(); } catch (RuntimeException runtimeException) { // In case of an unexpected exception you may want to abort // the HTTP request in order to shut down the underlying // connection immediately. httpGetRequest.abort(); runtimeException.printStackTrace(); } // try { // FileWriter file = new FileWriter("C:\\Users\\fred\\Desktop\\webicons\\output.json"); // file.write(bis.toJSONString()); // file.flush(); // file.close(); // // System.out.print(bis); // } catch (Exception e) { // } finally { // Closing the input stream will trigger connection release try { inputStream.close(); } catch (Exception ignore) { } } } } catch (ClientProtocolException e) { // thrown by httpClient.execute(httpGetRequest) e.printStackTrace(); } catch (IOException e) { // thrown by entity.getContent(); e.printStackTrace(); } finally { // When HttpClient instance is no longer needed, // shut down the connection manager to ensure // immediate deallocation of all system resources httpClient.getConnectionManager().shutdown(); } }