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.53k stars 4.02k forks source link

Wrong URL to access the Registry at startup #3618

Closed jdubois closed 8 years ago

jdubois commented 8 years ago

When I start my gateway and/or microservices, using the current master branch, I get this first line:

Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/gateway/default": Connection refused; nested exception is java.net.ConnectException: Connection refused

The registry is running on port 8761, not 8888, and this is normally correctly configured in the application-*.yml files, so I don't know where this port number comes from, but it's wrong.

gmarziou commented 8 years ago

Might be different but I usually get this when I use a profile that does not have any matching bootstrap-*.yml so registry url is not specified.

jdubois commented 8 years ago

Maybe it is because of the latest changes by @deepu105 -> maybe we don't have the dev profile anymore at boot time, and it is added afterwards.

russomi commented 8 years ago

I am seeing this on my side, too.

I am trying to run inside of Idea with a spring boot run configuration and my service cannot connect to the repo.

If I run the service via mvn from the command line, no error and I see the Config Server: Connected to the JHipster Registry config server! message.

i thought it could be related to the working directory specified in the run configuration, but that doesn't seem to solve it.

This one is annoying me.

russomi commented 8 years ago

@jdubois I believe you are headed in the right direction... I was able to resolve it by expliciting activating the 'dev' profile when running the service rather than allowing it to be defaulted.

deepu105 commented 8 years ago

I need to take a look. Maybe the default is not used at boot On 19 May 2016 23:14, "russomi" notifications@github.com wrote:

@jdubois https://github.com/jdubois I believe you are headed in the right direction... I was able to resolve it by expliciting activating the 'dev' profile when running the service rather than allowing it to be defaulted.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/jhipster/generator-jhipster/issues/3618#issuecomment-220355889

deepu105 commented 8 years ago

@jdubois Im trying to debug this, could you tell me how you started the registry and microservice? using docker or just using mvn spring-boot:run which profile for microservice?

jdubois commented 8 years ago

@deepu105 on the current master:

Now let me describe precisely so I'm sure you could reproduce:

deepu105 commented 8 years ago

Ok got it. But one more doubt. Before the change I did was this working with IDE? coz I thought we always had to set --spring.profiles.active=prod explicitly in IDE as the -Pprod was only in the gradle/maven build? and the dev profile was default anyway.

Btw which profile you used for the above?

But surely there seems to be some issue with the way spring treats profile set in the application.yml vs profile set using --spring.profiles.active=prod in arguments. Im seeing some issues with DB loading for prod profile in the war files. Ill dig deeper. I hate the spring boot magic sometimes :(

jdubois commented 8 years ago

I'm not running the IDE with any profile, so it should be in "dev" profile (which is what I want in my IDE anyway). Maybe I missed it, but for me this was working before.

deepu105 commented 8 years ago

I have opened a bug report to spring boot https://github.com/spring-projects/spring-boot/issues/5998

As the behavior is different from whats documented.

I guess the problem I faced with DB in prod is that when we set a spring.profiles.default spring boot loads up application.yml and application.dev.yml, when we set spring.profiles.active to prod spring boot loads up application.yml, application.prod.yml and application.dev.yml and hence some of the stuff like DB ends up reading from the dev properties.

I'm trying to find a fix using a listener with ApplicationListener<ApplicationEvent>

Ill post my findings, may be once I get this fixed ill have more clarity on what is the issue we have here

deepu105 commented 8 years ago

I didnt confirm this, could you plz confirm when you have time.

jdubois commented 8 years ago

@deepu105 I thought you tested it :-(

So big crash at startup now:

12:24:51.986 [main] DEBUG org.springframework.beans.factory.config.YamlPropertiesFactoryBean - Loading from YAML: class path resource [config/application.yml]
12:24:52.014 [main] DEBUG org.springframework.beans.factory.config.YamlPropertiesFactoryBean - Merging document (no matchers set): {eureka={instance={appname=gateway, instanceId=gateway:${spring.application.instance_id:${random.value}}}}, ribbon={eureka={enabled=true}}, zuul=null, management={context-path=/management, health={mail={enabled=false}}}, spring={application={name=gateway}, profiles={active=null}, jpa={open-in-view=false, hibernate={ddl-auto=none, naming-strategy=org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy}}, messages={basename=i18n/messages}, mvc={favicon={enabled=false}}, thymeleaf={mode=XHTML}}, security={basic={enabled=false}}, jhipster={async={corePoolSize=2, maxPoolSize=50, queueCapacity=10000}, mail={from=gateway@localhost}, swagger={title=gateway API, description=gateway API documentation, version=0.0.1, termsOfServiceUrl=null, contactName=null, contactUrl=null, contactEmail=null, license=null, licenseUrl=null}, ribbon={displayOnActiveProfiles=dev}}}
12:24:52.014 [main] DEBUG org.springframework.beans.factory.config.YamlPropertiesFactoryBean - Loaded 1 document from YAML resource: class path resource [config/application.yml]
12:24:52.014 [main] WARN io.github.jhipster.demo.config.DefaultProfileUtil - No Spring profile configured, running with default profile: dev
12:24:52.112 [restartedMain] DEBUG org.springframework.beans.factory.config.YamlPropertiesFactoryBean - Loading from YAML: class path resource [config/application.yml]
12:24:52.119 [restartedMain] DEBUG org.springframework.beans.factory.config.YamlPropertiesFactoryBean - Merging document (no matchers set): {eureka={instance={appname=gateway, instanceId=gateway:${spring.application.instance_id:${random.value}}}}, ribbon={eureka={enabled=true}}, zuul=null, management={context-path=/management, health={mail={enabled=false}}}, spring={application={name=gateway}, profiles={active=null}, jpa={open-in-view=false, hibernate={ddl-auto=none, naming-strategy=org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy}}, messages={basename=i18n/messages}, mvc={favicon={enabled=false}}, thymeleaf={mode=XHTML}}, security={basic={enabled=false}}, jhipster={async={corePoolSize=2, maxPoolSize=50, queueCapacity=10000}, mail={from=gateway@localhost}, swagger={title=gateway API, description=gateway API documentation, version=0.0.1, termsOfServiceUrl=null, contactName=null, contactUrl=null, contactEmail=null, license=null, licenseUrl=null}, ribbon={displayOnActiveProfiles=dev}}}
12:24:52.119 [restartedMain] DEBUG org.springframework.beans.factory.config.YamlPropertiesFactoryBean - Loaded 1 document from YAML resource: class path resource [config/application.yml]
12:24:52.119 [restartedMain] WARN io.github.jhipster.demo.config.DefaultProfileUtil - No Spring profile configured, running with default profile: dev
2016-05-23 12:24:53.498 DEBUG 17668 --- [kground-preinit] org.jboss.logging                        : Logging Provider: org.jboss.logging.Slf4jLoggerProvider found via system property
2016-05-23 12:24:53.856 ERROR 17668 --- [  restartedMain] o.s.boot.SpringApplication               : Application startup failed

java.lang.UnsupportedOperationException: null
at java.util.AbstractMap.put(AbstractMap.java:209)
at     org.springframework.cloud.bootstrap.BootstrapApplicationListener.mergeDefaultProperties(BootstrapApplicationListener.java:177)
at     org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:146)
deepu105 commented 8 years ago

oops. I tested only monolith setup. I screwed up my docker setup so couldn't test this. Let me try it manually

Thanks & Regards, Deepu

On Mon, May 23, 2016 at 6:26 PM, Julien Dubois notifications@github.com wrote:

@deepu105 https://github.com/deepu105 I thought you tested it :-(

So big crash at startup now:

12:24:51.986 [main] DEBUG org.springframework.beans.factory.config.YamlPropertiesFactoryBean - Loading from YAML: class path resource [config/application.yml] 12:24:52.014 [main] DEBUG org.springframework.beans.factory.config.YamlPropertiesFactoryBean - Merging document (no matchers set): {eureka={instance={appname=gateway, instanceId=gateway:${spring.application.instance_id:${random.value}}}}, ribbon={eureka={enabled=true}}, zuul=null, management={context-path=/management, health={mail={enabled=false}}}, spring={application={name=gateway}, profiles={active=null}, jpa={open-in-view=false, hibernate={ddl-auto=none, naming-strategy=org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy}}, messages={basename=i18n/messages}, mvc={favicon={enabled=false}}, thymeleaf={mode=XHTML}}, security={basic={enabled=false}}, jhipster={async={corePoolSize=2, maxPoolSize=50, queueCapacity=10000}, mail={from=gateway@localhost}, swagger={title=gateway API, description=gateway API documentation, version=0.0.1, termsOfServiceUrl=null, contactName=null, contactUrl=null, contactEmail=null, license=null, licenseUrl=null}, ribbon={displayOnActiveProfiles=d ev}}} 12:24:52.014 [main] DEBUG org.springframework.beans.factory.config.YamlPropertiesFactoryBean - Loaded 1 document from YAML resource: class path resource [config/application.yml] 12:24:52.014 [main] WARN io.github.jhipster.demo.config.DefaultProfileUtil - No Spring profile configured, running with default profile: dev 12:24:52.112 [restartedMain] DEBUG org.springframework.beans.factory.config.YamlPropertiesFactoryBean - Loading from YAML: class path resource [config/application.yml] 12:24:52.119 [restartedMain] DEBUG org.springframework.beans.factory.config.YamlPropertiesFactoryBean - Merging document (no matchers set): {eureka={instance={appname=gateway, instanceId=gateway:${spring.application.instance_id:${random.value}}}}, ribbon={eureka={enabled=true}}, zuul=null, management={context-path=/management, health={mail={enabled=false}}}, spring={application={name=gateway}, profiles={active=null}, jpa={open-in-view=false, hibernate={ddl-auto=none, naming-strategy=org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy}}, messages={basename=i18n/messages}, mvc={favicon={enabled=false}}, thymeleaf={mode=XHTML}}, security={basic={enabled=false}}, jhipster={async={corePoolSize=2, maxPoolSize=50, queueCapacity=10000}, mail={from=gateway@localhost}, swagger={title=gateway API, description=gateway API documentation, version=0.0.1, termsOfServiceUrl=null, contactName=null, contactUrl=null, contactEmail=null, license=null, licenseUrl=null}, ribbon={displayOnActiveP rofiles=dev}}} 12:24:52.119 [restartedMain] DEBUG org.springframework.beans.factory.config.YamlPropertiesFactoryBean - Loaded 1 document from YAML resource: class path resource [config/application.yml] 12:24:52.119 [restartedMain] WARN io.github.jhipster.demo.config.DefaultProfileUtil - No Spring profile configured, running with default profile: dev 2016-05-23 12:24:53.498 DEBUG 17668 --- [kground-preinit] org.jboss.logging : Logging Provider: org.jboss.logging.Slf4jLoggerProvider found via system property 2016-05-23 12:24:53.856 ERROR 17668 --- [ restartedMain] o.s.boot.SpringApplication : Application startup failed

java.lang.UnsupportedOperationException: null at java.util.AbstractMap.put(AbstractMap.java:209) at org.springframework.cloud.bootstrap.BootstrapApplicationListener.mergeDefaultProperties(BootstrapApplicationListener.java:177) at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:146)

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/jhipster/generator-jhipster/issues/3618#issuecomment-220943519

jdubois commented 8 years ago

Hang on, I got a monolith working - maybe it's only for gateways... strange....

deepu105 commented 8 years ago

Ya when I tested monolith was working. The error looks strange

deepu105 commented 8 years ago

Im trying a gateway now

deepu105 commented 8 years ago

Btw I tested for all combinations of monolith. I couldnt test for gateway since I screwed my docker. I was lazy to run all mnually :D

deepu105 commented 8 years ago

Im able to reproduce it but no idea why it fails. Could the singleton map be causing any issue?

deepu105 commented 8 years ago

It indeed is the issue :scream: I dont understand whats the difference here. Anyway im pushing a fix right now

deepu105 commented 8 years ago

@jdubois its fixed and its working fine with gateway. Indeed the singleton map was causing issue