code: public static List getExceptions(Throwable cause)
      {
          List exceptions = new ArrayList(10);
          exceptions.add(cause);
          
          do
          {
              Throwable nextCause;
              try
              {
                  Method rootCause = cause.getClass().getMethod("getRootCause", new Class[]{});
                  nextCause = (Throwable) rootCause.invoke(cause, new Object[]{});
              }
              catch(Exception e)
              {
                  nextCause = cause.getCause();
              }
              if (cause == nextCause)
              {
                  break;
              }
              
              if (nextCause != null)
              {
                  exceptions.add(nextCause);
              }
              
              cause = nextCause;
          }
          while (cause != null);
          
          return exceptions;
      }
docs: <p>
  returns a list of all throwables (including the one you passed in) wrapped by the given throwable.
  In contrast to a simple call to <code>getClause()</code> on each throwable it will also check if
  the throwable class contain a method <code>getRootCause()</code> (e.g. ServletException or JspException)
  and call it instead.
  </p>
  <p>
  The first list element will your passed in exception, the last list element is the cause.
  </p>