Hey everyone. I’m getting the following error when trying to add Okta ApiClient to my Spring service.
The error is this:
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.okta.sdk.impl.client.DefaultClientBuilder.requestFactory(DefaultClientBuilder.java:471)
The following method did not exist:
'void org.springframework.http.client.HttpComponentsClientHttpRequestFactory.setHttpClient(org.apache.http.client.HttpClient)'
The calling method's class, com.okta.sdk.impl.client.DefaultClientBuilder, was loaded from the following location:
jar:file:/Users/filipe-lima/.m2/repository/com/okta/sdk/okta-sdk-impl/10.3.0/okta-sdk-impl-10.3.0.jar!/com/okta/sdk/impl/client/DefaultClientBuilder.class
The called method's class, org.springframework.http.client.HttpComponentsClientHttpRequestFactory, is available from the following locations:
jar:file:/Users/filipe-lima/.m2/repository/org/springframework/spring-web/6.0.8/spring-web-6.0.8.jar!/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.class
The called method's class hierarchy was loaded from the following locations:
org.springframework.http.client.HttpComponentsClientHttpRequestFactory: file:/Users/user/.m2/repository/org/springframework/spring-web/6.0.8/spring-web-6.0.8.jar
Action:
Correct the classpath of your application so that it contains compatible versions of the classes com.okta.sdk.impl.client.DefaultClientBuilder and org.springframework.http.client.HttpComponentsClientHttpRequestFactory
This is my POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.cision</groupId>
<artifactId>okta-spring-integration</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>okta-spring-integration</name>
<description>Okta Proof of Concept for Spring App</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>com.okta.spring</groupId>
<artifactId>okta-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>com.okta.sdk</groupId>
<artifactId>okta-sdk-api</artifactId>
<version>10.2.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.okta.sdk</groupId>
<artifactId>okta-sdk-impl</artifactId>
<version>10.3.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.okta.spring</groupId>
<artifactId>okta-spring-sdk</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.core5</groupId>
<artifactId>httpcore5</artifactId>
<version>5.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.14</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>