A Java Spring Boot application (mdfinfra-ms
) fails to start due to a 401 Unauthorized
error when initializing a Keycloak admin client. This causes the entire dependency graph of services (ApprovalController
, ProjectServiceImpl
, etc.) to break during Spring context initialization, ultimately resulting in a fatal UnsatisfiedDependencyException
.
http://localhost:8134
http://localhost:8080
mdf-test-local-java-admin-client
test
client_credentials
HTTP 401 Unauthorized
Keycloak responded with: "invalid_client"
Reason: "Client not enabled to retrieve service account"
KeycloakAdminConfig - Initializing Keycloak admin client for realm 'test', client 'mdf-test-local-java-admin-client' at '<http://localhost:8134>'.
KeycloakErrorHandler - Unauthorized (401): token missing or expired
SpringApplication - Application run failed: UnsatisfiedDependencyException โ caused by HTTP 401 during bean creation of keycloakAdminInstance