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.aurel.track.fieldType.runtime.system.text.SystemArchiveLevelRT.java
/** * Get the value to be shown from the database and then try to localize * @param value/*from ww w .j a v a 2s. c o m*/ * @param locale * @return */ @Override public String getShowValue(Object value, Locale locale) { String keySuffix = null; if (value == null) { return ""; } Integer intValue = null; try { intValue = (Integer) value; } catch (Exception e) { LOGGER.warn("Casting the value type " + value.getClass().getName() + " to Integer failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (intValue != null) { if (TWorkItemBean.ARCHIVE_LEVEL_ARCHIVED.equals(intValue)) { keySuffix = "archived"; } else { if (TWorkItemBean.ARCHIVE_LEVEL_DELETED.equals(intValue)) { keySuffix = "deleted"; } } } if (keySuffix != null) { String localizedLabel = LocalizeUtil .getLocalizedTextFromApplicationResources("common.archiveLevel." + keySuffix, locale); if (localizedLabel != null && localizedLabel.length() > 0) { return localizedLabel; } } return ""; }
From source file:io.bitsquare.statistics.StatisticsMain.java
@Override protected void doExecute(OptionSet options) { final BitsquareEnvironment environment = new BitsquareEnvironment(options); Statistics.setEnvironment(environment); UserThread.execute(() -> statistics = new Statistics()); Thread.UncaughtExceptionHandler handler = (thread, throwable) -> { if (throwable.getCause() != null && throwable.getCause().getCause() != null && throwable.getCause().getCause() instanceof BlockStoreException) { log.error(throwable.getMessage()); } else {//www . j av a 2 s . c om log.error("Uncaught Exception from thread " + Thread.currentThread().getName()); log.error("throwableMessage= " + throwable.getMessage()); log.error("throwableClass= " + throwable.getClass()); log.error("Stack trace:\n" + ExceptionUtils.getStackTrace(throwable)); throwable.printStackTrace(); log.error("We shut down the app because an unhandled error occurred"); // We don't use the restart as in case of OutOfMemory errors the restart might fail as well // The run loop will restart the node anyway... System.exit(EXIT_FAILURE); } }; Thread.setDefaultUncaughtExceptionHandler(handler); Thread.currentThread().setUncaughtExceptionHandler(handler); String maxMemoryOption = environment.getProperty(AppOptionKeys.MAX_MEMORY); if (maxMemoryOption != null && !maxMemoryOption.isEmpty()) { try { maxMemory = Integer.parseInt(maxMemoryOption); } catch (Throwable t) { log.error(t.getMessage()); } } UserThread.runPeriodically(() -> { Profiler.printSystemLoad(log); long usedMemoryInMB = Profiler.getUsedMemoryInMB(); if (!stopped) { if (usedMemoryInMB > (maxMemory - 100)) { log.warn( "\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n" + "We are over our memory warn limit and call the GC. usedMemoryInMB: {}" + "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n", usedMemoryInMB); System.gc(); usedMemoryInMB = Profiler.getUsedMemoryInMB(); Profiler.printSystemLoad(log); } final long finalUsedMemoryInMB = usedMemoryInMB; UserThread.runAfter(() -> { if (finalUsedMemoryInMB > maxMemory) { log.error( "\n\n############################################################\n" + "We shut down as we are over our memory limit. usedMemoryInMB: {}" + "\n############################################################\n\n", finalUsedMemoryInMB); System.exit(EXIT_FAILURE); } }, 1); } }, CHECK_MEMORY_PERIOD_SEC); while (true) { try { Thread.sleep(Long.MAX_VALUE); } catch (InterruptedException ignore) { } } }
From source file:kr.co.bitnine.octopus.frame.ConnectionManager.java
public void closePool(String dataSourceName) { LOG.info("close connection pool of the data source '" + dataSourceName + '"'); try {/*from w w w .jav a 2s . co m*/ poolingDriver.closePool(dataSourceName); } catch (SQLException e) { LOG.error(ExceptionUtils.getStackTrace(e)); } }
From source file:com.aurel.track.screen.action.AbstractTabAction.java
/** * Obtain the properties for tab//from w w w. j a v a 2 s . co m * load the tab from db * @return */ public String properties() { tab = getAbstractTabDesignBL().loadTab(componentID); String s = new AbstractScreenJSON() { }.encodeTabProperties(tab); 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:ke.co.tawi.babblesms.server.persistence.contacts.EmailDAO.java
/** * * @param contact//from ww w . j a v a 2 s .co m * @return a list of {@link Email}s belonging to this contact */ @Override public List<Email> getEmails(Contact contact) { List<Email> emails = new ArrayList<>(); try (Connection conn = dbCredentials.getConnection(); PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM Email WHERE contactuuid=?;");) { pstmt.setString(1, contact.getUuid()); try (ResultSet rset = pstmt.executeQuery();) { emails = beanProcessor.toBeanList(rset, Email.class); } } catch (SQLException e) { logger.error("SQL Exception when getting all emails of " + contact); logger.error(ExceptionUtils.getStackTrace(e)); } return emails; }
From source file:ke.co.tawi.babblesms.server.persistence.maskcode.MaskDAO.java
/** * @see ke.co.tawi.babblesms.server.persistence.maskcode.BabbleMaskDAO#getMasks(ke.co.tawi.babblesms.server.beans.account.Account) */// ww w.j a v a 2s. co m @Override public List<Mask> getMasks(Account account) { List<Mask> masklist = null; try (Connection conn = dbCredentials.getConnection(); PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM Mask WHERE accountuuid=?;");) { pstmt.setString(1, account.getUuid()); try (ResultSet rset = pstmt.executeQuery();) { masklist = beanProcessor.toBeanList(rset, Mask.class); } } catch (SQLException e) { logger.error("SQL Exception when getting all masks"); logger.error(ExceptionUtils.getStackTrace(e)); } return masklist; }
From source file:com.aurel.track.exchange.msProject.exchange.MsProjectExchangeBL.java
/** * Initializes the MsProjectImporterBean by import * * @param projectOrReleaseID/*from w ww.jav a 2s . c o m*/ * @param personBean * @param file * @param locale * @return * @throws MSProjectImportException */ public static MsProjectExchangeDataStoreBean initMsProjectExchangeBeanForImport(Integer projectOrReleaseID, TPersonBean personBean, File file, Locale locale) throws MSProjectImportException { MsProjectExchangeDataStoreBean msProjectExchangeDataStoreBean = MsProjectExchangeBL .createMsProjectExchangeBean(projectOrReleaseID, personBean, file, locale); try { ProjectReader reader; ProjectFile project; if ("mpp".equals(FilenameUtils.getExtension(file.getName()).toLowerCase()) || "mpt".equals(FilenameUtils.getExtension(file.getName()).toLowerCase())) { reader = new MPPReader(); project = reader.read(file); } else { reader = new MSPDIReader(); project = reader.read(file); } msProjectExchangeDataStoreBean.setProject(project); } catch (Exception ex) { LOGGER.error(ex.getMessage(), ex); LOGGER.debug(ExceptionUtils.getStackTrace(ex)); } MsProjectExchangeBL.loadMSProjectData(msProjectExchangeDataStoreBean, msProjectExchangeDataStoreBean.getProject()); List<Task> tasks = msProjectExchangeDataStoreBean.getTasks(); if (tasks == null || tasks.isEmpty()) { throw new MSProjectImportException("admin.actions.importMSProject.err.noTaskFound"); } // project specific data get from msProject's project // creation date is important only by import (for conflict handling) Date lastSavedDate = msProjectExchangeDataStoreBean.getProject().getProjectHeader().getLastSaved(); if (lastSavedDate == null) { lastSavedDate = new Date(); } msProjectExchangeDataStoreBean.setLastSavedDate(lastSavedDate); return msProjectExchangeDataStoreBean; }
From source file:com.cognifide.aet.worker.impl.CollectorDispatcherImpl.java
private String getCause(AETException e) { String cause = e.getMessage(); if (StringUtils.isBlank(cause)) { cause = ExceptionUtils.getRootCauseMessage(e); }/* ww w. j a va 2s . com*/ if (StringUtils.isBlank(cause)) { cause = ExceptionUtils.getStackTrace(e); } return cause; }
From source file:com.aurel.track.dbase.UpdateDbSchema.java
public static boolean doUpdateOrCreateFromScratch(ServletContext servletContext) { Connection coni = null;/*from w ww. j a v a 2s .c o m*/ try { coni = InitDatabase.getConnection(); if (hasTables(coni)) { LOGGER.info("Database schema exists."); int migrateIndex = -1; int dbVersion = getDBVersion(coni); if (dbVersion != 0) { LOGGER.info("Database schema version is " + dbVersion); if (dbVersion < UpgradeDatabase.DBVERSION && dbVersion > 200) { migrateIndex = getMigrateScriptIndex(dbVersion); runMigrateScripts(migrateIndex, servletContext); } } } else { // create new database scheme LOGGER.info("Creating a new database schema..."); ApplicationStarter.getInstance().actualizePercentComplete( ApplicationStarter.getInstance().DB_TRACK_SCHEMA[0], ApplicationStarter.DB_SCHEMA_UPGRADE_SCRIPT_TEXT + " track-schema.sql..."); runSQLScript("track-schema.sql", Math.round(ApplicationStarter.DB_TRACK_SCHEMA[1] * 0.8f), ApplicationStarter.getInstance().getProgressText()); runSQLScript("id-table-schema.sql", Math.round(ApplicationStarter.DB_TRACK_SCHEMA[1] * 0.1f), ApplicationStarter.DB_SCHEMA_UPGRADE_SCRIPT_TEXT + " id-table-schema.sql..."); runSQLScript("quartz.sql", Math.round(ApplicationStarter.DB_TRACK_SCHEMA[1] * 0.1f), ApplicationStarter.DB_SCHEMA_UPGRADE_SCRIPT_TEXT + " quartz.sql..."); } return true; } catch (Exception e) { return false; } finally { try { if (coni != null) coni.close(); } catch (Exception e) { LOGGER.info("Closing the connection failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } }
From source file:com.aurel.track.lucene.index.associatedFields.AttachmentIndexer.java
/** * Adds an attachment to the attachment index * Used by attaching a new file to the workItem * @param attachFile/*from w w w .j a v a 2s. co m*/ */ @Override public void addToIndex(Object object, boolean add) { if (!LuceneUtil.isUseLucene() || !LuceneUtil.isIndexAttachments() || object == null) { return; } if (!ClusterBL.indexInstantly()) { LOGGER.debug("Index instantly is false"); return; } IndexWriter indexWriter = LuceneIndexer.getIndexWriter(getIndexWriterID()); if (indexWriter == null) { LOGGER.error("IndexWriter null by adding an attachment"); return; } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Save a new " + add + " attachment into attachmentIndex"); } TAttachmentBean attachmentBean = (TAttachmentBean) object; if (!add) { Integer objectID = attachmentBean.getObjectID(); if (objectID != null) { Term keyTerm = new Term(getObjectIDFieldName(), objectID.toString()); try { indexWriter.deleteDocuments(keyTerm); indexWriter.commit(); } catch (IOException e) { LOGGER.error("Removing the attachment " + objectID + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } } try { Document doc = createDocument(attachmentBean); if (doc != null) { indexWriter.addDocument(doc); } } catch (IOException e) { LOGGER.error("Adding an attachment to the index failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } try { indexWriter.commit(); } catch (IOException e) { LOGGER.error("Flushing the attachment failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } }