javaspring-bootokhttpsslsocketfactory

How to solve java.lang.UnsupportedOperationException: clientBuilder.sslSocketFactory(SSLSocketFactory) not supported on JDK 9+?


I get the error below every time I try to run a project. I did set the Project SDK to java 8, tried open jdk as well as oracle jdk, but still I get the error below. I worked with this project before and had no problems, but it does not run on my new computer. On this machine I had java 11 installed before, but I deleted it. I am using a mac.

Does anyone know why I get this error?

Thank You in Advance.

enter image description here

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getClientHttpRequestFactory' defined in class path resource [com/vocalink/bps/reporting/config/RestTemplateConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.http.client.ClientHttpRequestFactory]: Factory method 'getClientHttpRequestFactory' threw exception; nested exception is java.lang.UnsupportedOperationException: clientBuilder.sslSocketFactory(SSLSocketFactory) not supported on JDK 9+

Solution

  • The problem is in the jdk version. There are 2 solutions to this problem:

    1. update okhttp version;
    2. use an older jdk (used 1.8.0_202 and it worked).