Java 1.4 introduced the getCause () method for the Throwable class, which is the parent of all exception classes. If you need to get the stack trace as a string, you can use ExceptionUtils.getStackTrace (e) or something like this:
Exception e = ... StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); String stack Trace = sw.toString();
See additional discussion about removing methods from ExceptionUtil for JIRA LANG-491 issue .
source share