generator-jhipster icon indicating copy to clipboard operation
generator-jhipster copied to clipboard

Eureka doesn't start with customized keycloak

Open paris0120 opened this issue 3 years ago • 0 comments

Overview of the issue

I have a customized keycloak server running on 9080 (https://github.com/paris0120/keycloak-server) to replace the docker one. The realm profile is exported from the docker example. The frontend/gateway can login with the new server. However, I can't start the docker eureka server. I got the following errors. The eureka server works with the docker eureka server provided by jhipster.

docker-jhipster-registry-1 | 2022-07-02 13:17:34.912 ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed docker-jhipster-registry-1 | docker-jhipster-registry-1 | org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'OAuth2SecurityConfiguration' defined in file [/app/classes/tech/jhipster/registry/config/OAuth2SecurityConfiguration.class]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.zalando.problem.spring.web.advice.security.SecurityProblemSupport': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.OAuth2ClientConfiguration$OAuth2ClientWebMvcSecurityConfiguration': Unsatisfied dependency expressed through method 'setClientRegistrationRepository' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientRegistrationRepository' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2ClientRegistrationRepositoryConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository]: Factory method 'clientRegistrationRepository' threw exception; nested exception is java.lang.IllegalArgumentException: Unable to resolve Configuration with the provided Issuer of "http://keycloak:9080/auth/realms/jhipster"

Motivation for or Use Case

Customized keycloak server

Reproduce the error

Start mysql Start the keycloak server downloaded from https://github.com/paris0120/keycloak-server Start the eureka server: docker compose -f jhipster-register.yml up

Docker compose yml:

This configuration is intended for development purpose, it's your responsibility to harden it for production

version: '3.8' services: jhipster-registry: image: jhipster/jhipster-registry:v7.3.0 volumes: - ./central-server-config:/central-config # When run with the "dev" Spring profile, the JHipster Registry will # read the config from the local filesystem (central-server-config directory) # When run with the "prod" Spring profile, it will read the configuration from a Git repository # See https://www.jhipster.tech/jhipster-registry/#spring-cloud-config environment: - _JAVA_OPTIONS=-Xmx512m -Xms256m - SPRING_PROFILES_ACTIVE=dev,api-docs,oauth2 - SPRING_SECURITY_USER_PASSWORD=admin - JHIPSTER_REGISTRY_PASSWORD=admin - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_TYPE=native - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_SEARCH_LOCATIONS=file:./central-config/localhost-config/ # - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_TYPE=git # - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_URI=https://github.com/jhipster/jhipster-registry/ # - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_SEARCH_PATHS=central-config # For keycloak to work, you need to add '127.0.0.1 keycloak' to your hosts file - SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_OIDC_ISSUER_URI=http://keycloak:9080/auth/realms/jhipster - SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_ID=jhipster-registry - SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_SECRET=jhipster-registry # If you want to expose these ports outside your dev PC, # remove the "127.0.0.1:" prefix ports: - 127.0.0.1:8761:8761

Keyclock profile: https://github.com/paris0120/keycloak-server/blob/main/src/main/resources/realm-export.json

Related issues
Suggest a Fix
JHipster Version(s)
JHipster configuration
Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System
  • [ ] Checking this box is mandatory (this is just to show you read everything)

paris0120 avatar Jul 02 '22 14:07 paris0120