code: public static byte[] toByteArrayKryo(Object obj, ClassLoader classLoader) {
          if (obj == null) {
              return null;
          }
          Kryo kryo = kryoPool.obtain();
          try {
              ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
              if (classLoader != null) {
                  Thread.currentThread().setContextClassLoader(classLoader);
              }
              try {
                  Output output = kryoOutputPool.obtain();
                  try {
                      kryo.setClassLoader(classLoader != null ? classLoader : oldClassLoader);
                      // kryo.writeObject(output, obj);
                      kryo.writeClassAndObject(output, obj);
                      output.close();
                      return output.toBytes();
                  } catch (Exception e) {
                      throw e instanceof SerializationException ? (SerializationException) e
                              : new SerializationException(e);
                  } finally {
                      kryoOutputPool.free(output);
                  }
              } finally {
                  Thread.currentThread().setContextClassLoader(oldClassLoader);
              }
          } finally {
              kryoPool.free(kryo);
          }
      }
docs: Serialize an object to byte array, with a custom class loader.
  
  <p>
  This method uses Kryo lib.
  </p>
  
  @param obj
  @param classLoader
  @return