Search code examples
javaokhttpconfigcat

Can not create a new client instance for ConfigCat (configcat-java-client-6.0.1)


I want to implement config cat in my java 8 project.

The way I am creating a config cat client is this:

import com.configcat.ConfigCatClient;
public class ConfigCatClientUtil {

    public ConfigCatClientUtil() {
    }

    public ConfigCatClient createClient(String configCatKey) {
        ConfigCatClient configCatClient = null;
        try {
            configCatClient = new ConfigCatClient(configCatKey);
        } catch (Exception e) {
        }
        return configCatClient;
    }

}

The problem is that when try to execute this new ConfigCatClient(configCatKey) throws an error:

messages Feb 11 13:11:38 server: Caused by: java.lang.NoClassDefFoundError: okhttp3/Callback

I am using configcat-java-client-6.0.1.jar. Does anyone know why I am getting this error?


Solution

  • This library has a direct dependency on OkHttp

    https://mvnrepository.com/artifact/com.configcat/configcat-java-client/6.0.1

    If you are following their documentation you wouldn't see this, so I suggest starting with their instructions for setting up your maven or Gradle build.

    https://configcat.com/docs/sdk-reference/java/