diff --git a/integration/adapter-core/src/main/java/org/keycloak/adapters/authentication/ClientCredentialsProviderUtils.java b/integration/adapter-core/src/main/java/org/keycloak/adapters/authentication/ClientCredentialsProviderUtils.java index be3eb41e55..3a7b1c3826 100644 --- a/integration/adapter-core/src/main/java/org/keycloak/adapters/authentication/ClientCredentialsProviderUtils.java +++ b/integration/adapter-core/src/main/java/org/keycloak/adapters/authentication/ClientCredentialsProviderUtils.java @@ -1,8 +1,10 @@ package org.keycloak.adapters.authentication; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.ServiceConfigurationError; import java.util.ServiceLoader; import org.apache.http.NameValuePair; @@ -55,8 +57,17 @@ public class ClientCredentialsProviderUtils { } private static void loadAuthenticators(Map authenticators, ClassLoader classLoader) { - for (ClientCredentialsProvider authenticator : ServiceLoader.load(ClientCredentialsProvider.class, classLoader)) { - authenticators.put(authenticator.getId(), authenticator); + Iterator iterator = ServiceLoader.load(ClientCredentialsProvider.class, classLoader).iterator(); + while (iterator.hasNext()) { + try { + ClientCredentialsProvider authenticator = iterator.next(); + logger.debugf("Loaded clientCredentialsProvider %s", authenticator.getId()); + authenticators.put(authenticator.getId(), authenticator); + } catch (ServiceConfigurationError e) { + if (logger.isDebugEnabled()) { + logger.debug("Failed to load clientCredentialsProvider with classloader: " + classLoader, e); + } + } } }