Getting this error where I tried to call the Apps API from my local spring boot application

Hi all,

I am planning to build a local app that can call Apps API to add application to Okta. But when I run my application locally I get the below error.

SEVERE: Servlet.service() for servlet [dispatcherServlet] in context with path threw exception [Handler dispatch failed: java.lang.NoSuchMethodError: ‘void org.springframework.http.client.HttpComponentsClientHttpRequestFactory.setHttpClient(org.apache.http.client.HttpClient)’] with root cause
java.lang.NoSuchMethodError: ‘void org.springframework.http.client.HttpComponentsClientHttpRequestFactory.setHttpClient(org.apache.http.client.HttpClient)’
at com.okta.sdk.impl.client.DefaultClientBuilder.requestFactory(DefaultClientBuilder.java:454)
at com.okta.sdk.impl.client.DefaultClientBuilder.restTemplate(DefaultClientBuilder.java:430)
at com.okta.sdk.impl.client.DefaultClientBuilder.build(DefaultClientBuilder.java:352)

My gradle looks like this along with other dependencies :

implementation ‘org.apache.httpcomponents.client5:httpclient5:5.2.1’
implementation ‘org.apache.httpcomponents.core5:httpcore5:5.2.1’
implementation ‘org.apache.httpcomponents:httpclient:4.5.14’
implementation ‘com.okta.sdk:okta-sdk-api:10.2.0’
implementation ‘com.okta.sdk:okta-sdk-impl:10.2.0’

Please let me know if anyone knows the fix for this?

Thanks in advance

Looks like its compatability between Spring and Okta for using Apache HttpClient

NOTE: Requires Apache HttpComponents 5.1 or higher, as of Spring 6.0.

com.okta.sdk.impl.client.DefaultClientBuilder uses - org.apache.http.impl.client
Any plan on updating to the newer version of Apache HttpClients - org.apache.hc.client5 ?

Hello,

You might want to check this issue and add your use-case to it.

thank you,

1 Like