jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.54k stars 4.02k forks source link

can't get Spring Cloud config http://localhost:8761/config/fwmapp/prod/master": Connection refused (Connection refused); #6319

Closed awangseason closed 7 years ago

awangseason commented 7 years ago
Overview of the issue

I'm running my application in Docker, but my app couldn't get spring cloud config file at http://localhost:8761/config/fwmapp/prod/master but my jhipster-registry is running successfully at http://localhost:8761 Application 'jhipster-registry' is running! Access URLs: fwmapp-mysql_1 | 2017-09-06T03:25:10.761345Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check. jhipster-registry_1 | Local: http://localhost:8761 jhipster-registry_1 | External: http://172.18.0.4:8761 jhipster-registry_1 | Profile(s): [dev]

fwmapp-app_1 | 2017-09-06 05:54:06.843 ERROR 8 --- [ main] o.s.boot.SpringApplication : Application startup failed fwmapp-app_1 | fwmapp-app_1 | java.lang.IllegalStateException: Could not locate PropertySource and the fail fast property is set, failing fwmapp-app_1 | at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:132) fwmapp-app_1 | at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:93) fwmapp-app_1 | at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:567) fwmapp-app_1 | at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:338) fwmapp-app_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:301) fwmapp-app_1 | at com.delta.it.fwm.FwmappApp.main(FwmappApp.java:68) fwmapp-app_1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) fwmapp-app_1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) fwmapp-app_1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) fwmapp-app_1 | at java.lang.reflect.Method.invoke(Method.java:498) fwmapp-app_1 | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) fwmapp-app_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) fwmapp-app_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) fwmapp-app_1 | at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:59) fwmapp-app_1 | Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8761/config/fwmapp/prod/master": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused) fwmapp-app_1 | at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:666) fwmapp-app_1 | at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613) fwmapp-app_1 | at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:531) fwmapp-app_1 | at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.getRemoteEnvironment(ConfigServicePropertySourceLocator.java:172) fwmapp-app_1 | at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:93) fwmapp-app_1 | ... 13 common frames omitted

Motivation for or Use Case

I currently used JHipster to generate an application.

Reproduce the error

use standard steps to generate a JHipster application in app.yml:

version: '2'
services:
    fwmapp-app:
        image: fwmapp
        environment:
            - SPRING_PROFILES_ACTIVE=prod,swagger
            - EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE=http://admin:admin@localhost:8761/#/eureka
            - SPRING_CLOUD_CONFIG_URI=http://admin:admin@localhost:8761/config
            - SPRING_DATASOURCE_URL=jdbc:mysql://fwmapp-mysql:3306/fwmapp?useUnicode=true&characterEncoding=utf8&useSSL=false
            - JHIPSTER_SLEEP=30 # gives time for the JHipster Registry to boot before the application
            - SPRING_DATA_ELASTICSEARCH_CLUSTER_NODES=fwmapp-elasticsearch:9300
        ports:
            - 8080:8080
    fwmapp-mysql:
        extends:
            file: mysql.yml
            service: fwmapp-mysql
    fwmapp-elasticsearch:
        extends:
            file: elasticsearch.yml
            service: fwmapp-elasticsearch
    jhipster-registry:
        extends:
            file: jhipster-registry.yml
            service: jhipster-registry
        environment:
            - SPRING_CLOUD_CONFIG_SERVER_NATIVE_SEARCH_LOCATIONS=file:./central-config/docker-config/

in application.yml(under central-server-config/docker-config, central-server-config/localhost-config ): -- I'm not sure if this file is used by docker, and when it will be used

configserver:
    name: Docker JHipster Registry
    status: Connected to the JHipster Registry running in Docker

jhipster:
    security:
        authentication:
            jwt:
                secret: my-secret-token-to-change-in-production

eureka:
    client:
        service-url:
            defaultZone: http://admin:${jhipster.registry.password}@jhipster-registry:8761/eureka/
jhipster:
    registry:
        password: admin
Related issues

https://github.com/jhipster/generator-jhipster/issues/3176

Suggest a Fix

I've notice that "jhipster.registry.password" was introduced in below issue, but how to set this property is not indicated in anywhere. I've change it back to 'admin'. https://github.com/jhipster/generator-jhipster/issues/4905

JHipster Version(s)

generator-jhipster@4.7.0

JHipster configuration

Using JHipster version installed locally in current project's node_modules Executing jhipster:info Options: Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
fwmapp@0.0.0 /Users/awangseason/Documents/Project/JH/foreign-workers-management-app
├── generator-jhipster@4.7.0 
└── UNMET PEER DEPENDENCY popper.js@^1.11.0
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.delta.it.fwm",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "4.7.0",
    "baseName": "fwmapp",
    "packageName": "com.delta.it.fwm",
    "packageFolder": "com/delta/it/fwm",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "hibernateCache": "ehcache",
    "clusteredHttpSession": false,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Memory",
    "prodDatabaseType": "mysql",
    "searchEngine": "elasticsearch",
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "maven",
    "enableSocialSignIn": false,
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "replaced-by-jhipster-info",
    "clientFramework": "angularX",
    "useSass": false,
    "clientPackageManager": "npm",
    "applicationType": "monolith",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "otherModules": [
      {
        "name": "generator-jhipster-docker",
        "version": "2.2.0"
      }
    ],
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": [
      "en"
    ]
  }
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions ##### **Environment and Tools** java version "1.8.0_05" Java(TM) SE Runtime Environment (build 1.8.0_05-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode) git version 2.11.0 (Apple Git-81) node: v6.11.2 npm: 3.10.10 yeoman: 2.0.0 Docker version 17.06.1-ce, build 874a737 docker-compose version 1.14.0, build c7bdf9e ##### **Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory** not an error during an entity creation or associated with a specific entity ##### **Browsers and Operating System** not a problem with all browsers - [ ] Checking this box is mandatory (this is just to show you read everything)
awangseason commented 7 years ago

I used ./mvnw package -Pprod docker:build to create duckor image: In bootstrap-prod.yml:


spring:
    cloud:
        config:
            fail-fast: true
            retry:
                initial-interval: 1000
                max-interval: 2000
                max-attempts: 100
            uri: http://admin:${jhipster.registry.password}@localhost:8761/config
            # name of the config server's property source (file.yml) that we want to use
            name: fwmapp
            profile: prod # profile(s) of the property source
            label: master # toggle to switch to a different version of the configuration as stored in git
            # it can be set to any label, branch or commit of the configuration source Git repository

jhipster:
    registry:
        password: admin
jdubois commented 7 years ago

I don't understand why your registry is on localhost, and not on jhipster-registry - how did you generate your Docker Compose file, did you use our docker-compose sub-generator?

awangseason commented 7 years ago

because my jhipster registry is running in a docker container on my laptop. Docker log: Application 'jhipster-registry' is running! Access URLs: jhipster-registry_1 | Local: http://localhost:8761 jhipster-registry_1 | External: http://172.18.0.4:8761 jhipster-registry_1 | Profile(s): [dev]

So I change the config in in app.yml, from jhipster-registry to localhost.

PierreBesson commented 7 years ago

@awangseason This is not how docker works. When you run docker-compose up, docker will create a virtual "bridge" network. So from inside your fwmapp-app container the registry address would be jhipster-registry:8761. However when accessing from your host (outside docker) the address is indeed localhost:8761. This should be properly configured by JHipster. https://docs.docker.com/compose/networking/

awangseason commented 7 years ago

Thanks. May I ask how to pass the variable ${jhipster.registry.password} to app.yml?

jdubois commented 7 years ago

Hi, this is the ticket system: if you have a bug with our docker-compose sub-generator, we will try to solve it. If you have a general question, on your own custom configuration, then you should go to Stack Overflow. We're there too, and you will get help there.

jdubois commented 7 years ago

This ticket has been closed as the guidelines are not followed.

Tickets must follow our Guidelines, as mentioned in:

  1. our Readme file on the front page of the project,
  2. the "create a new ticket" page and
  3. our Help page

We have also created a template on the "create a new ticket" page to help you follow those guidelines.

Open a new issue with proper details or update this issue with all details and request to reopen. Issues opened without proper details will be closed without explanation.

If you have a question please use Stack Overflow for that. Tag the question with jhipster and someone will help you out there.

This helps us to keep our issue tracker clean. Also, Stack Overflow will give your query a larger audience.

AhHa45 commented 2 years ago

man if we're already here just answer the question...