Example usage for org.apache.commons.lang3.exception ExceptionUtils getStackTrace

List of usage examples for org.apache.commons.lang3.exception ExceptionUtils getStackTrace

Introduction

In this page you can find the example usage for org.apache.commons.lang3.exception ExceptionUtils getStackTrace.

Prototype

public static String getStackTrace(final Throwable throwable) 

Source Link

Document

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) .

Usage

From source file:c3.ops.priam.utils.RetryableCallable.java

public T call() throws Exception {
    int retry = 0;
    int logCounter = 0;
    while (true) {
        try {//from w w w .j  a va  2 s. c  om
            return retriableCall();
        } catch (CancellationException e) {
            throw e;
        } catch (Exception e) {
            retry++;
            if (retry == retrys) {
                throw e;
            }
            logger.error(String.format("Retry #%d for: %s", retry, e.getMessage()));

            if (++logCounter == 1)
                logger.error("Exception --> " + ExceptionUtils.getStackTrace(e));
            Thread.sleep(waitTime);
        } finally {
            forEachExecution();
        }
    }
}

From source file:com.aurel.track.dbase.UpdateDbSchema.java

/**
 * Gets the database version//w  ww.  j a  va2  s .co  m
 * @param dbConnection
 * @return
 */
public static int getDBVersion(Connection dbConnection) {
    Statement istmt = null;
    ResultSet rs = null;
    try {
        istmt = dbConnection.createStatement();
        rs = istmt.executeQuery("SELECT DBVERSION FROM TSITE");
        if (rs == null || !rs.next()) {
            LOGGER.info("TSITE is empty.");
        } else {
            return rs.getInt(1);
        }
    } catch (Exception e) {
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    } finally {
        try {
            if (rs != null) {
                rs.close();
            }
        } catch (Exception e) {
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
        try {
            if (istmt != null) {
                istmt.close();
            }
        } catch (Exception e) {
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
        try {
            if (dbConnection != null) {
                dbConnection.close();
            }
        } catch (Exception e) {
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
    }
    return 0;
}

From source file:com.aurel.track.lucene.index.associatedFields.textExctractor.DocExtractor.java

/**
 * Gets the text from file content //ww w.  ja  va 2s. c  o m
 * @param file
 * @param fileExtension
 * @return
 */
@Override
public String getText(File file, String fileExtension) {
    FileInputStream fis = null;
    try {
        fis = new FileInputStream(file);
        WordTextExtractorFactory wordTextExtractorFactory = new WordTextExtractorFactory();
        return wordTextExtractorFactory.textExtractor(fis).getText();
    } catch (FileNotFoundException e) {
        LOGGER.info("File " + file.getName() + " not found. " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    } catch (Exception e) {
        LOGGER.debug("Extracting text from the .doc file " + file.getName() + " failed with " + e.getMessage());
        LOGGER.error(ExceptionUtils.getStackTrace(e));
    } finally {
        try {
            if (fis != null) {
                fis.close();
            }
        } catch (IOException e) {
            LOGGER.debug("Closing the FileInputStream for file " + file.getName() + " failed with "
                    + e.getMessage());
            LOGGER.error(ExceptionUtils.getStackTrace(e));
        }
    }
    return null;
}

From source file:com.gatf.executor.executor.SingleTestCaseExecutor.java

public List<TestCaseReport> execute(TestCase testCase, TestCaseExecutorUtil testCaseExecutorUtil) {

    WorkflowContextHandler workflowContextHandler = testCaseExecutorUtil.getContext()
            .getWorkflowContextHandler();

    TestCaseReport testCaseReport = new TestCaseReport();
    testCaseReport.setTestCase(testCase);
    testCaseReport.setNumberOfRuns(1);/*from  www.  j a v  a 2 s.c o  m*/

    try {
        workflowContextHandler.handleContextVariables(testCase, new HashMap<String, String>(),
                testCaseExecutorUtil.getContext());
    } catch (Exception e) {
        testCaseReport.setExecutionTime(0L);
        testCaseReport.setStatus(TestStatus.Failed.status);
        testCaseReport.setFailureReason(TestFailureReason.Exception.status);
        testCaseReport.setError(e.getMessage());
        testCaseReport.setErrorText(ExceptionUtils.getStackTrace(e));
        if (e.getMessage() == null && testCaseReport.getErrorText() != null
                && testCaseReport.getErrorText().indexOf("\n") != -1) {
            testCaseReport.setError(
                    testCaseReport.getErrorText().substring(0, testCaseReport.getErrorText().indexOf("\n")));
        }

        e.printStackTrace();

        List<TestCaseReport> lst = new ArrayList<TestCaseReport>();
        lst.add(testCaseReport);
        return lst;
    }

    ListenableFuture<TestCaseReport> report = testCaseExecutorUtil.executeTestCase(testCase, testCaseReport);
    try {
        testCaseReport = report.get();
    } catch (Exception e) {
        testCaseReport.setStatus(TestStatus.Failed.status);
        testCaseReport.setError(e.getMessage());
        testCaseReport.setErrorText(ExceptionUtils.getStackTrace(e));
        e.printStackTrace();
    }

    List<TestCaseReport> lst = new ArrayList<TestCaseReport>();
    lst.add(testCaseReport);
    return lst;
}

From source file:com.xtesy.core.internals.impl.Settings.java

/**
 * @author Wasiq B//from   ww  w  .  j a  v  a  2s.  co m
 * @since 31-May-2015 9:23:00 pm
 */
private Settings() {
    super();
    log.entry();
    try {
        addConfiguration(new SystemConfiguration());
        parseConfig();
    } catch (final ConfigurationException | FileNotFoundException e) {
        try {
            throw new FrameworkException("Load Settings", e);
        } catch (final FrameworkException e1) {
            log.catching(e1);
            log.error(ExceptionUtils.getRootCauseMessage(e1));
            log.error(ExceptionUtils.getStackTrace(e1));
        }
    } finally {
        log.exit();
    }
}

From source file:com.aurel.track.fieldType.fieldChange.converter.CustomSelectSetterConverter.java

/**
 * Convert the string to object value after load
 * @param value//from   w  ww .  j  av a  2s  .c  o m
 * @param setter
 * @return
 */
@Override
public Object getActualValueFromStoredString(String value, Integer setter) {
    if (value == null || value.trim().length() == 0 || setter == null) {
        return null;
    }
    switch (setter) {
    case FieldChangeSetters.SET_TO:
        Integer intValue = null;
        try {
            intValue = Integer.valueOf(value);
        } catch (Exception e) {
            LOGGER.warn("Converting the " + value + " to Integer failed with " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
        if (intValue != null) {
            return new Integer[] { intValue };
        }
    }
    return null;
}

From source file:com.aurel.track.persist.TBLOBPeer.java

/**
 * Gets a TBLOBBean by primary key //from w w w.j  av a2s  .  co  m
 * @param objectID
 * @return
 */
@Override
public TBLOBBean loadByPrimaryKey(Integer objectID) {
    TBLOB tBlob = null;
    try {
        tBlob = retrieveByPK(objectID);
    } catch (Exception e) {
        LOGGER.debug("Loading of a blob by primary key " + objectID + " failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (tBlob != null) {
        return tBlob.getBean();
    }
    return null;
}

From source file:com.aurel.track.lucene.index.associatedFields.textExctractor.HTMLExtractor.java

/**
 * Gets the text from file content //from   w ww .j  a va 2s  .  com
 * @param file
 * @param fileExtension
 * @return
 */
@Override
public String getText(File file, String fileExtension) {
    FileInputStream fis = null;
    Reader reader = null;
    try {
        try {
            fis = new FileInputStream(file);
        } catch (FileNotFoundException e) {
            LOGGER.info("File " + file.getName() + " not found. " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
            return null;
        }
        reader = new BufferedReader(new InputStreamReader(fis));
        DefaultStyledDocument dsd = new DefaultStyledDocument();
        HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
        htmlEditorKit.read(reader, dsd, 0);
        return dsd.getText(0, dsd.getLength());
    } catch (Exception e) {
        LOGGER.debug("Extracting text from the .htm or .html  file " + file.getName() + " failed with "
                + e.getMessage());
        LOGGER.error(ExceptionUtils.getStackTrace(e));
    } finally {
        try {
            if (reader != null) {
                reader.close();
            }
        } catch (Exception e) {
            LOGGER.debug("Closing the reader for file " + file.getName() + " failed with " + e.getMessage());
        }
        try {
            if (fis != null) {
                fis.close();
            }
        } catch (Exception e) {
            LOGGER.debug("Closing the FileInputStream for file " + file.getName() + " failed with "
                    + e.getMessage());
        }
    }
    return null;
}

From source file:com.aurel.track.fieldType.fieldChange.converter.IntegerSetterConverter.java

/**
 * Convert the string to object value after load
 * @param value/*from  ww  w.j  ava  2 s.c o m*/
 * @param setter
 * @return
 */
@Override
public Object getActualValueFromStoredString(String value, Integer setter) {
    if (value == null || "".equals(value) || setter == null) {
        return null;
    }
    switch (setter.intValue()) {
    case FieldChangeSetters.SET_TO:
    case FieldChangeSetters.ADD_IF_SET:
    case FieldChangeSetters.ADD_OR_SET:
        try {
            return Integer.valueOf(value);
        } catch (Exception e) {
            LOGGER.warn("Converting the " + value + " to Integer failed with " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
    }
    return null;
}

From source file:com.aurel.track.fieldType.fieldChange.converter.SystemSelectSetterConverter.java

/**
 * Convert the string to object value after load
 * @param value/*from   www. jav  a  2 s .co m*/
 * @param setter
 * @return
 */
@Override
public Object getActualValueFromStoredString(String value, Integer setter) {
    if (value == null || value.trim().length() == 0 || setter == null) {
        return null;
    }
    switch (setter) {
    case FieldChangeSetters.SET_TO:
        Integer intValue = null;
        try {
            intValue = Integer.valueOf(value);
            return intValue;
        } catch (Exception e) {
            LOGGER.warn("Converting the " + value + " to Integer failed with " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
    }
    return null;
}