code: private void serializePreviousException() {
          try {
              final ByteArrayOutputStream bas = new ByteArrayOutputStream();
              ObjectOutputStream oos = (ObjectOutputStream) AccessController.doPrivileged(new PrivilegedExceptionAction() {
                  @Override
                  public Object run() throws IOException {
                      return new ObjectOutputStream(bas);
                  }
              });
              oos.writeObject(previousExceptionObject);
              previousException = bas.toByteArray();
          } catch (PrivilegedActionException pae) {
              pae.getException().printStackTrace();
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
docs: Set the previous exception attribute. The exception will be
  converted to a byte array, so that an unmarshall exception will
  not be thrown if the exception doesn't exist on the client or on
  an intermediate server.
  
  @param exception java.lang.Throwable