code: public static Throwable getCause(Throwable e) {
          Throwable cause = null; 
          Throwable result = e;
          while (null != (cause = result.getCause()) && (result != cause)) {
              result = cause;
          }
          return result;
      }
docs: find the root cause of an exception, for nested BeansException case