List of usage examples for org.apache.commons.lang3.exception ExceptionUtils getStackTrace
public static String getStackTrace(final Throwable throwable)
Gets the stack trace from a Throwable as a String.
The result of this method vary by JDK version as this method uses Throwable#printStackTrace(java.io.PrintWriter) .
From source file:com.linkedin.pinot.controller.api.restlet.resources.PinotInstance.java
@Override @Get//from ww w . java 2 s .com public Representation get() { StringRepresentation presentation = null; try { final String instanceName = (String) getRequest().getAttributes().get(INSTANCE_NAME); final String status = getReference().getQueryAsForm().getValues(STATUS); if (status == null) { presentation = new StringRepresentation("Not a valid GET call, do nothing!"); } else { if (status.equals(ENABLE)) { presentation = new StringRepresentation( manager.enableInstance(instanceName).toJSON().toString()); } if (status.equals(DISABLE)) { presentation = new StringRepresentation( manager.disableInstance(instanceName).toJSON().toString()); } } } catch (final Exception e) { presentation = new StringRepresentation(e.getMessage() + "\n" + ExceptionUtils.getStackTrace(e)); LOGGER.error("Caught exception while processing post request", e); setStatus(Status.SERVER_ERROR_INTERNAL); } return presentation; }
From source file:com.aurel.track.exchange.track.exporter.TrackExportAction.java
@Override public String execute() { List<ReportBean> reportBeanList = null; List<Integer> selectedWorkItemIDs = null; if (workItemIDs != null && !"".equals(workItemIDs)) { //selections in item navigator selectedWorkItemIDs = GeneralUtils.createIntegerListFromStringArr(workItemIDs.split(",")); reportBeanList = LoadItemIDListItems.getReportBeansByWorkItemIDs( GeneralUtils.createIntArrFromIntegerList(selectedWorkItemIDs), false, personID, locale, true, true, true, true, true, true, false, false, false); } else {/*from w ww.j ava2s . c o m*/ //no selections, get the result of the last executed query QueryContext queryContext = ItemNavigatorBL.loadLastQuery(personBean.getObjectID(), locale); if (queryContext != null) { try { reportBeanList = ItemNavigatorBL.executeQuery(personBean, locale, queryContext); } catch (TooManyItemsToLoadException e) { LOGGER.info("Number of items to load " + e.getItemCount()); } } } DownloadUtil.prepareResponse(ServletActionContext.getRequest(), response, "TrackReport.zip", "application/zip"); OutputStream outputStream = null; try { outputStream = response.getOutputStream(); } catch (IOException e) { LOGGER.warn("Getting the output stream failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (outputStream != null) { TrackExportBL.exportWorkItemsWithAttachments(reportBeanList, personID, outputStream); } return null; }
From source file:com.gatf.executor.dataprovider.SQLDatabaseTestDataSource.java
public void init() { Thread currentThread = Thread.currentThread(); ClassLoader oldClassLoader = currentThread.getContextClassLoader(); try {//w w w . ja va 2s . c om currentThread.setContextClassLoader(getProjectClassLoader()); if (args == null || args.length == 0) { throw new AssertionError("No arguments passed to the DatabaseProvider"); } if (args.length < 4) { throw new AssertionError("All 4 arguments, namely jdbcUrl, jdbcDriver, dbUserName and" + "dbPassword are mandatory for DatabaseProvider"); } Assert.assertNotNull("jdbcUrl cannot be empty", args[0]); Assert.assertNotNull("jdbcDriver cannot be empty", args[1]); Assert.assertNotNull("dbUserName cannot be empty", args[2]); Assert.assertNotNull("dbPassword cannot be empty", args[3]); jdbcUrl = args[0].trim(); String jdbcDriver = args[1].trim(); dbUserName = args[2].trim(); dbPassword = args[3].trim(); Assert.assertFalse("jdbcUrl cannot be empty", jdbcUrl.isEmpty()); Assert.assertFalse("jdbcDriver cannot be empty", jdbcDriver.isEmpty()); Assert.assertFalse("dbUserName cannot be empty", dbUserName.isEmpty()); StringBuilder build = new StringBuilder(); build.append("DatabaseTestDataSource configuration [\n"); build.append(String.format("jdbcUrl is %s\n", jdbcUrl)); build.append(String.format("jdbcDriver is %s\n", jdbcDriver)); build.append(String.format("dbUserName is %s\n", dbUserName)); build.append(String.format("dbPassword is %s]", dbPassword)); logger.info(build.toString()); //Load the driver first try { Driver driver = (Driver) getProjectClassLoader().loadClass(jdbcDriver).newInstance(); CustomDriverManager.registerDriver(driver); } catch (Exception e) { throw new AssertionError(String.format("Driver class %s not found", jdbcDriver)); } for (int i = 0; i < poolSize; i++) { //Now try connecting to the Database Connection conn = null; try { conn = CustomDriverManager.getConnection(jdbcUrl, dbUserName, dbPassword); } catch (Exception e) { throw new AssertionError(String.format( "Connection to the Database using the JDBC URL %s failed with the error %s", jdbcUrl, ExceptionUtils.getStackTrace(e))); } addToPool(conn, false); } } catch (Exception t) { t.printStackTrace(); } finally { currentThread.setContextClassLoader(oldClassLoader); } }
From source file:com.s3auth.rest.TkApp.java
/** * Authenticated./*from w w w. j a v a2 s . c o m*/ * @param takes Take * @return Authenticated takes */ private static Take fallback(final Take takes) { return new TkFallback(takes, new FbChain(new FbStatus(HttpURLConnection.HTTP_NOT_FOUND, new TkNotFound()), // @checkstyle AnonInnerLengthCheck (50 lines) new Fallback() { @Override public Iterator<Response> route(final RqFallback req) throws IOException { final String err = ExceptionUtils.getStackTrace(req.throwable()); return Collections.<Response>singleton(new RsWithStatus(new RsWithType( new RsVelocity(this.getClass().getResource("exception.html.vm"), new RsVelocity.Pair("err", err), new RsVelocity.Pair("rev", TkApp.REV)), "text/html"), HttpURLConnection.HTTP_INTERNAL_ERROR)).iterator(); } })); }
From source file:com.mbrlabs.mundus.editor.utils.Log.java
public static void exception(String tag, Throwable e) { String stack = ExceptionUtils.getStackTrace(e); fatal(tag, stack); }
From source file:com.hpe.caf.worker.testing.ProcessorDeliveryHandler.java
private String buildFailedMessage(TestItem testItem, Throwable throwable) { StringBuilder sb = new StringBuilder(); sb.append("Test case failed."); TestCaseInfo info = testItem.getTestCaseInformation(); if (info != null) { sb.append(" Test case id: " + info.getTestCaseId()); sb.append("\nTest case description: " + info.getDescription()); sb.append("\nTest case comments: " + info.getComments()); sb.append("\nTest case associated tickets: " + info.getAssociatedTickets()); sb.append("\n"); }/*from w ww . j a va 2s .co m*/ sb.append("Message: " + ExceptionUtils.getMessage(throwable)); sb.append("\n"); sb.append("Root cause message: " + ExceptionUtils.getRootCauseMessage(throwable)); sb.append("\nStack trace:\n"); sb.append(ExceptionUtils.getStackTrace(throwable)); return sb.toString(); }
From source file:io.stallion.templating.TemplateRenderer.java
public String render500Html(Exception e) { String friendlyMessage = "There was an error trying to handle your request."; if (e instanceof WebException) { friendlyMessage = ((WebException) e).getMessage(); } else if (e instanceof InvocationTargetException) { if (((InvocationTargetException) e).getTargetException() != null) { if (((InvocationTargetException) e).getTargetException() instanceof WebException) { friendlyMessage = ((InvocationTargetException) e).getTargetException().getMessage(); }/*from w w w . j av a 2 s . c o m*/ } } String error = ""; if (Context.getSettings().getDebug()) { error += "\nStacktrace-----------------------------------\n\n"; error += e.toString() + "\n\n"; error += ExceptionUtils.getStackTrace(e); error = error.replace("\n", "<br>\n"); } try { Map<String, Object> context = getErrorContext(); context.put("errorDebugMessage", error); context.put("friendlyMessage", friendlyMessage); if (getJinjaTemplating().templateExists("templates/public/500.jinja")) { return renderTemplate("templates/public/500.jinja", context); } else { URL url = getClass().getClassLoader().getResource("templates/public/500.jinja"); return renderTemplate(url.toString(), context); } } catch (Exception e2) { Log.warn("---------------Exception trying to render the 500 page-------------"); Log.exception(e2, "500 rendering exception"); Log.warn("---------------End 500 rendering exception-------------"); String error2 = ""; if (Context.getSettings().getDebug()) { error2 += "\nSecond Stacktrace trying to render the error!-----------------------------------\n\n"; error2 += e2.toString() + "\n\n"; error2 += ExceptionUtils.getStackTrace(e2); error2 = error2.replace("\n", "<br>\n"); } String html = "The server encountered an error trying to handle your request. Please try again in a little bit." + error + error2; return html; } }
From source file:com.aurel.track.dbase.Migrate411To412.java
/** * Add the document and document section * Use JDBC because negative objectIDs should be added */// www . j a v a2 s .c o m public static void addNewItemTypes() { LOGGER.info("Add new item types"); List<String> itemTypeStms = new ArrayList<String>(); TListTypeBean docIssueTypeBean = IssueTypeBL.loadByPrimaryKey(-4); if (docIssueTypeBean == null) { LOGGER.info("Add 'Document' item type"); itemTypeStms.add(addItemtype(-4, "Document", 4, -4, "document.png", "2007")); } TListTypeBean docSectionIssueTypeBean = IssueTypeBL.loadByPrimaryKey(-5); if (docSectionIssueTypeBean == null) { LOGGER.info("Add 'Document section' item type"); itemTypeStms.add(addItemtype(-5, "Document section", 5, -5, "documentSection.png", "2008")); } Connection cono = null; try { cono = InitDatabase.getConnection(); Statement ostmt = cono.createStatement(); cono.setAutoCommit(false); for (String filterClobStmt : itemTypeStms) { ostmt.executeUpdate(filterClobStmt); } cono.commit(); cono.setAutoCommit(true); } catch (Exception e) { LOGGER.debug(ExceptionUtils.getStackTrace(e)); } finally { try { if (cono != null) { cono.close(); } } catch (Exception e) { LOGGER.info("Closing the connection failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } //children types List<TChildIssueTypeBean> childIssueTypeBeans = ChildIssueTypeAssignmentsBL .loadByChildAssignmentsByParent(-4); if (childIssueTypeBeans == null || childIssueTypeBeans.isEmpty()) { //document may have only document section children ChildIssueTypeAssignmentsBL.save(-4, -5); } TListTypeBean actionItemIssueTypeBean = IssueTypeBL.loadByPrimaryKey(5); TListTypeBean meetingIssueTypeBean = IssueTypeBL.loadByPrimaryKey(-3); if (actionItemIssueTypeBean != null && meetingIssueTypeBean != null) { //action item exists childIssueTypeBeans = ChildIssueTypeAssignmentsBL.loadByChildAssignmentsByParent(-3); if (childIssueTypeBeans == null || childIssueTypeBeans.isEmpty()) { //meeting may have only action item children ChildIssueTypeAssignmentsBL.save(-3, 5); } } }
From source file:com.aurel.track.screen.action.AbstractPanelAction.java
/** * Obtain the properties for the panel//from w w w. j a v a 2s .co m * @return */ public String properties() { panel = getAbstractPanelDesignBL().loadPanel(componentID); String s = new AbstractScreenJSON() { }.encodePanelProperties(panel); try { JSONUtility.prepareServletResponseJSON(ServletActionContext.getResponse()); PrintWriter out = ServletActionContext.getResponse().getWriter(); out.println(s); } catch (IOException e) { // TODO Auto-generated catch block LOGGER.error(ExceptionUtils.getStackTrace(e)); } return null; }
From source file:com.braffdev.server.core.io.logger.Logger.java
/** * Logs the given Throwable with the <code>ERROR</code> tag. * * @param t/* w ww .j a va 2 s. c o m*/ */ public void error(Throwable t) { this.buildLogMessage("ERROR", ExceptionUtils.getStackTrace(t)); }