Issue
I have a java web application secured with OKTA. I have the below code which throws the below exception,
Client client = Clients.builder()
.setOrgUrl((String)SessionUtils.getSession().getAttribute("serverUrl"))
.setClientCredentials(new TokenClientCredentials((String)SessionUtils.getSession().getAttribute("apiKey")))
.build();
When I run it, I get the below error. I have tried adding the jar by going to the buildPath of eclipse project. I am using the below dependencies in my POM and this used to work before when my project had an ANT build. But I started getting this error when I moved to Maven.
java.lang.IllegalStateException: Unable to find a 'com.okta.sdk.impl.http.RequestExecutorFactory' implementation on the classpath. Please ensure you have added the okta-sdk-httpclient.jar file to your runtime classpath. at com.okta.commons.lang.Classes.lambda$loadFromService$0(Classes.java:205) at java.util.Optional.orElseThrow(Optional.java:290) at com.okta.commons.lang.Classes.loadFromService(Classes.java:205) at com.okta.sdk.impl.client.BaseClient.createRequestExecutor(BaseClient.java:103) at com.okta.sdk.impl.client.BaseClient.(BaseClient.java:72) at com.okta.sdk.impl.client.AbstractClient.(AbstractClient.java:60) at com.okta.sdk.impl.client.DefaultClient.(DefaultClient.java:117) at com.okta.sdk.impl.client.DefaultClientBuilder.build(DefaultClientBuilder.java:322)
Solution
I could resolve this by using the okta-sdk-httpclient :v1.5.2 to match some of the other OKTA dependencies that I had in my project.
Below are the dependencies that I had in my project prior to the fix.
-okta-authn-sdk-api :v1.0.0
-okta-authn-sdk-impl :v1.0.0
-okta-http-api :v1.2.8
-okta-commons-lang :v1.2.8
-okta-config-check :v1.2.8
-okta-http-okhttp :v1.2.8
-okta-jwt-verifier :v0.5.1
-okta-jwt-verifier-impl:v0.4.0
-okta-sdk :v0.0.4
-okta-sdk-api :v1.5.2
-okta-sdk-httpclient :v6.0.0
-okta-sdk-impl :v1.5.2
Answered By - user2101
Answer Checked By - David Marino (JavaFixing Volunteer)