Generator-jhipster: jhipster 4.0 microservice : eureka password error

Created on 20 Feb 2017  Β·  24Comments  Β·  Source: jhipster/generator-jhipster

I'm creating a new microservices project.

I'm using JHipster 4.0.5 and, according this issue [https://github.com/jhipster/generator-jhipster/issues/4905] Eureka password is define by jhipster.registry.password

So, in application-dev.yml Eureka configuration is, by default :

eureka: instance: prefer-ip-address: true client: enabled: true healthcheck: enabled: true registerWithEureka: true fetchRegistry: true serviceUrl: defaultZone: http://admin:${jhipster.registry.password}@localhost:8761/eureka/

in the file bootstrap-dev.yml the password definition is look good:

jhipster: registry: password: admin

When I launch my gateway (or microservice) I've got this error message

2017-02-17 10:32:12.794 ERROR 2064 --- [ restartedMain] c.n.d.s.t.d.RedirectingEurekaHttpClient : Request execution error

java.lang.IllegalArgumentException: Illegal character in authority at index 7: http://admin:${jhipster.registry.password}@localhost:8761/eureka/

at java.net.URI.create(URI.java:852)

at com.sun.jersey.api.client.Client.resource(Client.java:434)

at com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.getApplicationsInternal(AbstractJerseyEurekaHttpClient.java:187)

Work fine when I change my Eureka configuration in application-dev.yml to :
defaultZone: http://admin:admin@localhost:8761/eureka/

My configuration

  • JHipster version : 4.0.5
  • Project : microservices
  • Registry version : 2.5.8
  • OS : Windows 7 64bits
  • Launch from IDE Intellj

Thanks

All 24 comments

I'm pinging @PierreBesson because he did this change.

I have no idea what's wrong here, because I can't reproduce, but you're not the first one to mention this.

-> I want to go back to the old "admin:admin" in the default zone, that was much better. We had no issue, and people could still configure the password (OK, they were configuring the whole URL, but that wasn't really an issue).

In the meantime, yes the trick is to do like you, defaultZone: http://admin:admin@localhost:8761/eureka/

@JulienVincendeau :

  • at the start of your app, do you have this line:
2017-02-18 00:16:25.197  WARN 19283 --- [  restartedMain] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/sample/default": Connexion refusΓ©e (Connection refused); nested exception is java.net.ConnectException: Connexion refusΓ©e (Connection refused)
  • can you use yo jhipster:info and provide all information ?

@jdubois
It's a pity beacause it's really a good idea
I'm on Windows environnement, is-it a track?

@pascalgrimaud
yes i've got many time this error which have no incidence on my service's registry
I've got this error on the previous version 4.x too

Microsoft Windows [version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. Tous droits rΓ©servΓ©s.

yo jhipster:info
Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
[email protected] C:\workspace.jhipster\referentiels-hsm\referentiels-gw
`-- [email protected]

JHipster configuration, a .yo-rc.json file generated in the root folder
{
  "generator-jhipster": {
    "jhipsterVersion": "4.0.3",
    "baseName": "gateway",
    "packageName": "fr.xx.referentiels.gw",
    "packageFolder": "fr/xx/referentiels/gw",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "hibernateCache": "hazelcast",
    "clusteredHttpSession": false,
    "websocket": "spring-websocket",
    "databaseType": "sql",
    "devDatabaseType": "postgresql",
    "prodDatabaseType": "postgresql",
    "searchEngine": "elasticsearch",
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "maven",
    "enableSocialSignIn": false,
    "jwtSecretKey": "1670dbb7953f02163d692x5d0e33d933",
    "useSass": false,
    "clientPackageManager": "npm",
    "applicationType": "gateway",
    "testFrameworks": [
      "gatling",
      "protractor"
    ],
    "jhiPrefix": "jhi",
    "enableTranslation": true,
    "nativeLanguage": "fr",
    "languages": [
      "fr"
    ],
    "clientFramework": "angular1"
  }
}
Entity configuration(s) entityName.json files generated in the .jhipster directory

ls: no such file or directory: .jhipster/*.json

Browsers and Operating System

java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

git version 2.8.1.windows.1

node: v6.9.1

npm: 4.2.0

bower: 1.8.0

gulp:
[15:18:32] CLI version 1.2.2
[15:18:32] Local version 3.9.1

yeoman: 1.8.5

@JulienVincendeau Thank you for your .yo-rc.json. I'm looking into it right now;

The reason I added this registry.password property was to facilitate secure and replicated eureka servers but if it cause some problems then sadly we will have to go back to admin:admin. But I want to be sure that there is a bug here.

Yes sorry about this @PierreBesson -> yes your idea is great, and I have no idea where the bug might be. But this isn't the first time we have this kind of feedback since we migrated, so I guess there's a link.
BTW I'm doing microservices right now with your config, and I have no issue with it, it works perfectly (in Docker for Mac).

@JulienVincendeau : it's because the password is defined here https://github.com/jhipster/generator-jhipster/blob/master/generators/server/templates/src/main/resources/config/_bootstrap-dev.yml#L26-L28

And if the profile is not loaded properly, you got the warn Could not locate PropertySource and the application can't read the bootstrap-dev.yml, so the password is not defined. It's pretty similar to https://github.com/jhipster/generator-jhipster/issues/5240 so I think there is something wrong. I will try to investigate

I just tested it and it works like a charm when launching with mvn, it might be connected to launching from IDE and setting the correct spring profile there.

Maybe it's because @JulienVincendeau you configured it in a way that we didn't expect: can you explain exactly how you configure and start your services?

@PierreBesson :

Just generated a fresh project. I use my MicroApp main class to start my application.
Here the logs:

2017-02-20 15:38:19.184 DEBUG 20617 --- [kground-preinit] org.jboss.logging                        : Logging Provider: org.jboss.logging.Slf4jLoggerProvider found via system property

        β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
        β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘ β•šβ•β•β–ˆβ–ˆβ•”β•β•β• β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•— β–ˆβ–ˆβ•”β•β•β•β•β• β•šβ•β•β–ˆβ–ˆβ•”β•β•β• β–ˆβ–ˆβ•”β•β•β•β•β•β• β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—
        β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘    β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—     β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
  β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ•”β•β•β•β•β•   β•šβ•β•β•β–ˆβ–ˆβ•—    β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ•”β•β•β•β•   β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘
  β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘       β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•    β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘  β•šβ–ˆβ–ˆβ•—
   β•šβ•β•β•β•β•β•  β•šβ•β•   β•šβ•β• β•šβ•β•β•β•β•β•β•β• β•šβ•β•       β•šβ•β•β•β•β•β•     β•šβ•β•    β•šβ•β•β•β•β•β•β•β• β•šβ•β•   β•šβ•β•

:: JHipster πŸ€“  :: Running Spring Boot 1.4.4.RELEASE ::
:: http://jhipster.github.io ::

2017-02-20 15:38:19.817  WARN 20617 --- [  restartedMain] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/micro/default": Connection refused; nested exception is java.net.ConnectException: Connection refused
2017-02-20 15:38:19.820  INFO 20617 --- [  restartedMain] io.github.pascalgrimaud.MicroApp         : The following profiles are active: swagger,dev

(...)

java.lang.IllegalArgumentException: Illegal character in authority at index 7: http://admin:${jhipster.registry.password}@localhost:8761/eureka/
    at java.net.URI.create(URI.java:852)
    at com.sun.jersey.api.client.Client.resource(Client.java:434)
    at com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.getApplicationsInternal(AbstractJerseyEurekaHttpClient.java:187)
    at com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.getApplications(AbstractJerseyEurekaHttpClient.java:165)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137)
    at com.netflix.discovery.shared.transport.decorator.MetricsCollectingEurekaHttpClient.execute(MetricsCollectingEurekaHttpClient.java:73)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134)

If I add -Dspring.profiles.active=dev in VM Options of my IntelliJ, it works.

@jdubois I'm using the IDE IntelliJ CE. I'm creating Services with the out-of-box configuration according your video (https://youtu.be/dOO-8cAKDu8)
So i launch my gw/services directly from IntelliJ CE (CTRL+MAJ+F10)

@pascalgrimaud maybe I don't well configured my IntelliJ because i still have the problem.

Don't worry, it's just to give you this problem but my project is not block

I am having the same problem. The problem exists both running with Gradle or IntellijIDEA.

As @pascalgrimaud states there is a warning: Could not locate PropertySource

I also reproduced the error. When booting with default config from IntelliJ, it does not work. The app is correctly started in the dev profile but it doesn't read properties from bootstrap-dev.yaml. This is normal because the default profile is only set in main class initApplication() which I assume is run after the special "bootstrap" phase of the config server.

The solution is the one suggested by @pascalgrimaud πŸ‘ , set the dev profile in IDE, I tested the following, they all fix the problem :

  • This checkbox (IDEA ultimate)
    screen shot 2017-02-20 at 17 08 09
  • This one (I know IDEA community has this)
    screen shot 2017-02-20 at 17 10 47
  • This one :
    screen shot 2017-02-20 at 17 13 06
  • And even this one :
    screen shot 2017-02-20 at 17 19 15

So it's not a bug of the registry property, it is the normal tricky behaviour of spring cloud config. I don't know how we could work around this. Anyway it only concerns microservices and gateway that are run from IDE. We really need to document this better, maybe with a diagram.

Oh, that's because they don't read the profile at the right time? That's pretty bad!
Then, I would really want to revert to the old "admin:admin" stuff in the application-*.yml file as:

  • It doesn't have this very weird issue, that will annoy a lot of people
  • You don't lose any thing, it's just that the configuration isn't as clean as it could be

@jdubois When you revert to admin:admin in case the profile is not set, although it does not fail but it does not mean that it actually works ! I just tested and in this case although eureka discovery is working but then the configserver fails as it is using the default configserver url ("http://localhost:8888/gateway/default"). @pascalgrimaud Can you confirm that what I'm saying is correct ?

yes you're correct @PierreBesson !

Playing a little bit this morning:

Playing a little bit too

  • I replace #spring.profiles.active# by dev and it's works for me too

For your information, with the configuration defaultZone: http://admin:admin@localhost:8761/eureka/ I've got this error
Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/application/default": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect

This error appear with JHipster 3.x too

I've got IntelliJ default configuration on Windows

I have submitted a PR to the docs: https://github.com/jhipster/jhipster.github.io/pull/398
@JulienVincendeau is it enough to close this issue for you ?

@PierreBesson and can't we have "dev" by default in the bootstrap.yml? It really worries me that we have something not working by default.
Sorry about that, but I'm re-opening, I want something better than just documentation. The great thing with JHipster is that it all works out of the box normally.

But we can't have "dev" by default since the value is supposed to be filled out by maven/gradle (so that we can switch between dev and prod).

For application.yml we can bypass this by setting the dev profile at runtime if no profile is found but we cannot cheat like that with the bootstrap config. I would really like to find a solution/workaround as well but I don't see one.

And what if we copy/paste the content of bootstrap-dev.yml inside bootstrap.yml?

  • When no profile is selected, we go in dev mode
  • When the prod profile is selected, this configuration is overridden by bootstrap-prod.yml

@jdubois thanks for this re-opened ticket
I change bootstrap-dev.yml and bootstrap.yml as you have proposed

bootstrap.yml
spring:
    application:
        name: gateway
    profiles:
        # The commented value for `active` can be replaced with valid Spring profiles to load.
        # Otherwise, it will be filled in by maven when building the WAR file
        # Either way, it can be overridden by `--spring.profiles.active` value passed in the commandline or `-Dspring.profiles.active` set in `JAVA_OPTS`
        active: #spring.profiles.active#
    cloud:
        config:
            fail-fast: true
            uri: http://admin:${jhipster.registry.password}@localhost:8761/config

jhipster:
    registry:
        password: admin
bootstrap-dev.yml
# ===================================================================
# Spring Cloud Config bootstrap configuration for the "dev" profile
# ===================================================================

spring:
    cloud:
        config:
            # name of the config server's property source (file.yml) that we want to use
            name: gateway
            profile: dev # 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 config source git repository

application-dev.yml
            defaultZone: http://admin:${jhipster.registry.password}@localhost:8761/eureka/

My gateway started with no error indevmode. I've not try in prod mode.

For your information, in production mode (with JHIpster 4.x out-of-box config) we launch a service like that (no docker )
./jhipster-registry.war --spring.profiles.active=prod
and we not the error java.net.ConnectException: Connection refused: connect

When no profile is selected, we go in dev mode
When the prod profile is selected, this configuration is overridden by bootstrap-prod.yml

Yes this is a possible fix but it is not consistent with what we do with application-*.yml as you would need to be careful that every property that you define for dev is correctly overwritten by the prod one.
Also people will wonder where is the bootstrap-dev if you remove it completely. Then I'm not entirely against your proposition as it would "fix" the problem.

@JulienVincendeau you shoud not need to add --spring.profiles.active=prod if you have correctly build the jar with mvn package -Pprod.

Maybe it's a silly question but why we need to configure http://admin:${jhipster.registry.password}@localhost:8761/config on application-*.yml and bootstrap-*.yml ?

I've not your expertise to affirm properties I defined for dev will be correctly overwritten by the prod.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dronavallisaikrishna picture dronavallisaikrishna  Β·  3Comments

DanielFran picture DanielFran  Β·  3Comments

chegola picture chegola  Β·  4Comments

tomj0101 picture tomj0101  Β·  3Comments

SudharakaP picture SudharakaP  Β·  3Comments