Getting error while running test script to get OTP

Error: Exception in thread “main” java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.okta.commons.lang.Classes.(Classes.java:37)
at com.okta.sdk.client.Clients.builder(Clients.java:43)
at org.example.oktaTest.(oktaTest.java:20)
at org.example.Main.(Main.java:5)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
… 4 more

Code:
TokenClientCredentials clientCredentials = new TokenClientCredentials(apiToken);
ApiClient client = Clients.builder()
.setOrgUrl(“org - npm”)
.setClientCredentials(clientCredentials)
.build();

    System.out.println("client:"+client);

    //Retrieve the user's Okta Verify OTP:
    UserApi userApi = new UserApi(client);
    User user = userApi.getUser(userId);

Hi,

Are you adding the imports to sflogger to your code?

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Here is an example

1 Like