protected HttpEntity toJsonEntity(final Object obj) {

        String json = toJson(obj);

        try {
            return new JsonEntity(json);
        } catch (Exception ex) {
            Class clazz = null;
            if (obj != null) {
                clazz = obj.getClass();
            }
            throw new RuntimeException("failure, obj class=" + clazz, ex);
        }

    }