添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

java.lang.IllegalStateException: Could not locate PropertySource and the fail fast property is set, failing in Microservices

Ask Question

I am following Microservices from link: https://github.com/sqshq/PiggyMetrics . I was able to simply start the "config" service successfully, but when I tried to start the "registry" service, I got the below error.

Could anyone please guide on what is the issue ? I dont see any proper steps about setting or sequences to run the microservices.

2018-08-19 18:55:15.424  INFO 12700 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://config:8888
2018-08-19 18:55:17.805  INFO 12700 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://config:8888. Will be trying the next url if available
2018-08-19 18:55:17.826 ERROR 12700 --- [           main] o.s.boot.SpringApplication               : Application run failed
java.lang.IllegalStateException: Could not locate PropertySource and the fail fast property is set, failing
    at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:136) ~[spring-cloud-config-client-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:94) ~[spring-cloud-context-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:633) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:373) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at com.piggymetrics.registry.RegistryApplication.main(RegistryApplication.java:12) [classes/:na]
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://config:8888/registry/default": config; nested exception is java.net.UnknownHostException: config
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:732) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:680) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:600) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.getRemoteEnvironment(ConfigServicePropertySourceLocator.java:218) ~[spring-cloud-config-client-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:96) ~[spring-cloud-config-client-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    ... 7 common frames omitted
Caused by: java.net.UnknownHostException: config
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source) ~[na:1.8.0_151]
    at java.net.PlainSocketImpl.connect(Unknown Source) ~[na:1.8.0_151]
    at java.net.SocksSocketImpl.connect(Unknown Source) ~[na:1.8.0_151]
    at java.net.Socket.connect(Unknown Source) ~[na:1.8.0_151]
    at java.net.Socket.connect(Unknown Source) ~[na:1.8.0_151]
    at sun.net.NetworkClient.doConnect(Unknown Source) ~[na:1.8.0_151]
    at sun.net.www.http.HttpClient.openServer(Unknown Source) ~[na:1.8.0_151]
    at sun.net.www.http.HttpClient.openServer(Unknown Source) ~[na:1.8.0_151]
    at sun.net.www.http.HttpClient.<init>(Unknown Source) ~[na:1.8.0_151]
    at sun.net.www.http.HttpClient.New(Unknown Source) ~[na:1.8.0_151]
    at sun.net.www.http.HttpClient.New(Unknown Source) ~[na:1.8.0_151]
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source) ~[na:1.8.0_151]
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source) ~[na:1.8.0_151]
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) ~[na:1.8.0_151]
    at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source) ~[na:1.8.0_151]
    at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:76) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:723) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    ... 11 common frames omitted
                it says it cant connect to config host, try using ip addresses instead, and not "localhost", "config" or "127.0.0.1", something like 10.1.2.3. or 192.168.3.4
– Andrew
                Aug 19, 2018 at 13:30
                Right, I did that, its asking me to enter username and password, not sure what to put there. I think we need to tweak the config file of the project ? I am using Windows machine
– Jeff Cook
                Aug 19, 2018 at 13:32

You have provided 'config' as the hostname of config service. Replace it with proper hostname.

spring:
  application:
    name: <name>
  cloud:
    config:
      uri: http://host:port
      fail-fast: true
      password: <password>
      username: <user>

Since the application is not able to resolve 'config', it is giving you UnknownHost Exception.

Yes, but config has to be a proper hostname for it to work. You can either replace it with a hostname or an environment variable as $config. – S.K. Aug 19, 2018 at 13:39 Config service has to be started first, after that all services can be started in any order (assuming there is no dependency on any other service). – S.K. Aug 19, 2018 at 13:42 Ok, I started config, registry and gateway successfully, but for registry, console show some error - com.sun.jersey.api.client.ClientHandlerException: java.net.UnknownHostException: registry – Jeff Cook Aug 19, 2018 at 13:43 @JeffCook how did you solve it ? because i still get java.net.UnknownHostException: config on all services even though i added spring: application: name: config – valik Dec 27, 2019 at 9:42

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.