Skip to content

Building a RestTemplate using RestTemplateBuilder fails with a ClassNotFoundException when OkHttp 2 is on the classpath #13314

Closed
@jmirc

Description

@jmirc

I just updated a project with Spring Boot 2.0.2 and I am getting the following exception

Caused by: java.lang.IllegalArgumentException: Could not find class [org.springframework.http.client.OkHttpClientHttpRequestFactory]
	at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:313)
	at org.springframework.boot.web.client.RestTemplateBuilder.detectRequestFactory(RestTemplateBuilder.java:600)
	at org.springframework.boot.web.client.RestTemplateBuilder.configureRequestFactory(RestTemplateBuilder.java:566)
	at org.springframework.boot.web.client.RestTemplateBuilder.configure(RestTemplateBuilder.java:535)
	at org.springframework.boot.web.client.RestTemplateBuilder.build(RestTemplateBuilder.java:523)
	at org.springframework.boot.web.client.RestTemplateBuilder.build(RestTemplateBuilder.java:509)
	at org.springframework.boot.test.web.client.TestRestTemplate.<init>(TestRestTemplate.java:133)

The RestTemplateBuilder is trying to validate if some HTTP client factories exist and the org.springframework.http.client.OkHttpClientHttpRequestFactory doesn't exist anymore in Spring Framework.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions