2

thanks in advance for this awesome stack platform that is jhipster.

I have a question, I am trying to run a microservice directly with:

./mvnw -Pdev -DskipTests

And I am getting (UnknownHostException -- 'http://admin:admin@jhipster-registry:8761/eureka/):

2021-09-16 10:06:26.225  INFO 6762 --- [  restartedMain] c.n.d.s.t.d.RedirectingEurekaHttpClient  : Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://admin:admin@jhipster-registry:8761/eureka/}, exception=I/O error on GET request for "http://admin:admin@jhipster-registry:8761/eureka/apps/": jhipster-registry: Name or service not known; nested exception is java.net.UnknownHostException: jhipster-registry: Name or service not known stacktrace=org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://admin:admin@jhipster-registry:8761/eureka/apps/": jhipster-registry: Name or service not known; nested exception is java.net.UnknownHostException: jhipster-registry: Name or service not known
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:785)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:711)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:602)
at org.springframework.cloud.netflix.eureka.http.RestTemplateEurekaHttpClient.getApplic

My doubt is, why is trying to use the domain jhipster-registry:8761 instead of what I have in the dev configurations, "localhost"?

eureka:
  instance:
    prefer-ip-address: true
  client:
    service-url:
      defaultZone: http://admin:${jhipster.registry.password}@localhost:8761/eureka/

Right now I am using docker-compose in order to run the needed services, like the registry:

services:
  jhipster-registry:
    image: jhipster/jhipster-registry:v6.8.0
    volumes:
      - ./central-server-config:/central-config
    # By default the JHipster Registry runs with the "dev" and "native"
    # Spring profiles.
    # "native" profile means the filesystem is used to store data, see
    # http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html
    environment:
      - _JAVA_OPTIONS=-Xmx512m -Xms256m
      - JHIPSTER_SLEEP=20
      - SPRING_PROFILES_ACTIVE=dev,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
      # - 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
    ports:
      - 8761:8761
  keycloak:
    image: jboss/keycloak:12.0.4
    command:
      [
        "-b",
        "0.0.0.0",
        "-Dkeycloak.migration.action=import",
        "-Dkeycloak.migration.provider=dir",
        "-Dkeycloak.migration.dir=/opt/jboss/keycloak/realm-config",
        "-Dkeycloak.migration.strategy=OVERWRITE_EXISTING",
        "-Djboss.socket.binding.port-offset=1000",
        "-Dkeycloak.profile.feature.upload_scripts=enabled",
      ]
    volumes:
      - ./realm-config:/opt/jboss/keycloak/realm-config
    environment:
      - KEYCLOAK_USER=admin
      - KEYCLOAK_PASSWORD=admin
      - DB_VENDOR=h2
    ports:
      - 9080:9080
      - 9443:9443
      - 10990:10990
  test-mysql:
    container_name: test-mysql
    restart: always
    image: mysql:8.0.25
    environment:
      MYSQL_ROOT_PASSWORD: 'root'
    ports:
      # <Port exposed> : < MySQL Port running inside container>
      - '3306:3306'
    expose:
      # Opens port 3306 on the container
      - '3306'
    volumes:
      - test-datavolume:/var/lib/mysql
volumes:
  test-datavolume:

I know that if I add into the /etc/hosts the entry "127.0.0.1 jhipster-registry" is going to work, but I cant find/understand why is trying to use jhipster-registry instead of localhost?

Thanks!

Juano7894
  • 703
  • 1
  • 8
  • 21

0 Answers0