带RestTemplateBuilder的requestFactory

我有这段代码:

Class<? extends HttpComponentsClientHttpRequestFactory> theClazz = new MyHttpComponentFactoryBuilder().build().getClass();

        this.restTemplate = restTemplateBuilder
                .requestFactory(theClazz)
                .build();

But I have a InvocationTargetException / NullPointerException when running the restTemplateBuilder even when debugging theClazz is not null