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

Ribbon: instance can not be null error in Jhipster 4.13.3 #7007

Closed srinisubra closed 6 years ago

srinisubra commented 6 years ago

Hi there, I am trying a microservices app with UAA option. discoveryclient service seems to print all the services (discoveryClient.getServices()). But for some reason both Gateway and Microservice fails

2018-01-18 23:52:18.709 ERROR 10932 --- [  restartedMain] e.c.s.oauth2.UaaSignatureVerifierClient  : -----SERVICE------
2018-01-18 23:52:18.710  INFO 10932 --- [  restartedMain] e.c.s.oauth2.UaaSignatureVerifierClient  : =====>service : consul
2018-01-18 23:52:18.710  INFO 10932 --- [  restartedMain] e.c.s.oauth2.UaaSignatureVerifierClient  : =====>service : gateway
2018-01-18 23:52:18.710  INFO 10932 --- [  restartedMain] e.c.s.oauth2.UaaSignatureVerifierClient  : =====>service : uaa

 I am getting the following error in the log.  The following is from Microservice: 
Caused by: java.lang.IllegalArgumentException: **instance can not be null**
    at org.springframework.util.Assert.notNull(Assert.java:134)
    at org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.reconstructURI(RibbonLoadBalancerClient.java:48)
    at io.github.jhipster.security.uaa.LoadBalancedResourceDetails.getAccessTokenUri(LoadBalancedResourceDetails.java:50)
    at org.springframework.security.oauth2.client.token.OAuth2AccessTokenSupport.getAccessTokenUri(OAuth2AccessTokenSupport.java:156)
    at org.springframework.security.oauth2.client.token.OAuth2AccessTokenSupport.retrieveToken(OAuth2AccessTokenSupport.java:137)
    at org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsAccessTokenProvider.obtainAccessToken(ClientCredentialsAccessTokenProvider.java:44)
    at org.springframework.security.oauth2.client.token.AccessTokenProviderChain.obtainNewAccessTokenInternal(AccessTokenProviderChain.java:148)
    at org.springframework.security.oauth2.client.token.AccessTokenProviderChain.obtainAccessToken(AccessTokenProviderChain.java:121)
    at org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor.acquireAccessToken(OAuth2FeignRequestInterceptor.java:171)
    at org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor.getToken(OAuth2FeignRequestInterceptor.java:127)
    at org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor.extract(OAuth2FeignRequestInterceptor.java:112)
    at org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor.apply(OAuth2FeignRequestInterceptor.java:100)
    at feign.SynchronousMethodHandler.targetRequest(SynchronousMethodHandler.java:158)
--------------------
**From gatewayapp:**
Caused by: com.netflix.client.ClientException: **Load balancer does not have available server for client: uaa**
    at com.netflix.loadbalancer.LoadBalancerContext.getServerFromLoadBalancer(LoadBalancerContext.java:483)
    at com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:184)
    at com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:180)
    at rx.Observable.unsafeSubscribe(Observable.java:10211)
    at rx.internal.operators.OnSubscribeConcatMap.call(OnSubscribeConcatMap.java:94)
    at rx.internal.operators.OnSubscribeConcatMap.call(OnSubscribeConcatMap.java:42)
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
    at rx.Observable.subscribe(Observable.java:10307)
    at rx.Observable.subscribe(Observable.java:10274)
    at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:445)
    at rx.observables.BlockingObservable.single(BlockingObservable.java:342)
    at com.netflix.client.AbstractLoadBalancerAwareClient.executeWithLoadBalancer(AbstractLoadBalancerAwareClient.java:117)
    at org.springframework.cloud.netflix.zuul.filters.route.support.AbstractRibbonCommand.run(AbstractRibbonCommand.java:105)
    at org.springframework.cloud.netflix.zuul.filters.route.support.AbstractRibbonCommand.run(AbstractRibbonCommand.java:43)

Here is my .yo-rc.json from microservice

{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "mm.creativeone",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "4.13.3",
    "baseName": "app1",
    "packageName": "mm.creativeone",
    "packageFolder": "mm/creativeone",
    "serverPort": "8081",
    "authenticationType": "uaa",
    "uaaBaseName": "uaa",
    "hibernateCache": "hazelcast",
    "clusteredHttpSession": false,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "mariadb",
    "prodDatabaseType": "mariadb",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": "consul",
    "buildTool": "maven",
    "enableSocialSignIn": false,
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "ac8ffe7b0c093c65650d4c51c95e30fa57aac8ca",
    "enableTranslation": true,
    "applicationType": "microservice",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "nativeLanguage": "en",
    "languages": [
      "en",
      "nl",
      "fr"
    ],
    "clientPackageManager": "yarn",
    "skipClient": true,
    "skipUserManagement": true,
    "cacheProvider": "hazelcast",
    "enableHibernateCache": true
  }
}

UAA

{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "mm.creativeone",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "4.13.3",
    "baseName": "uaa",
    "packageName": "mm.creativeone",
    "packageFolder": "mm/creativeone",
    "serverPort": "9999",
    "authenticationType": "uaa",
    "hibernateCache": "hazelcast",
    "clusteredHttpSession": false,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "mariadb",
    "prodDatabaseType": "mariadb",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": "consul",
    "buildTool": "maven",
    "enableSocialSignIn": false,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "applicationType": "uaa",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "nativeLanguage": "en",
    "languages": [
      "en",
      "nl",
      "fr"
    ],
    "clientPackageManager": "yarn",
    "skipClient": true,
    "cacheProvider": "hazelcast",
    "enableHibernateCache": true
  }
}

gateway

{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "mm.creativeone",
      "nativeLanguage": "en",
      "microservicePath": "../micro"
    },
    "jhipsterVersion": "4.13.3",
    "baseName": "gateway",
    "packageName": "mm.creativeone",
    "packageFolder": "mm/creativeone",
    "serverPort": "8080",
    "authenticationType": "uaa",
    "uaaBaseName": "uaa",
    "cacheProvider": "hazelcast",
    "enableHibernateCache": false,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "mariadb",
    "prodDatabaseType": "mariadb",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": "consul",
    "buildTool": "maven",
    "enableSocialSignIn": false,
    "enableSwaggerCodegen": false,
    "clientFramework": "angularX",
    "useSass": true,
    "clientPackageManager": "yarn",
    "applicationType": "gateway",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": [
      "en",
      "fr"
    ]
  }
}
ruddell commented 6 years ago

I couldn't reproduce with your config. Based on the gateway's error, the UAA is not present in Consul's app list. Is it started? You should be able to see the UAA in Consul's UI http://localhost:8500/

srinisubra commented 6 years ago

Thank you, Ruddell. Consul is marking as failing. I don't see any errors in UAA. Do you think any firewall issue? Many thanks for your prompt reply

image

ruddell commented 6 years ago

If you click on the failing check in Consul's UI, it should show you more details. It could be a firewall issue, Consul's logs might have more details as well.

I'm closing this because it's not a bug or feature request. If you still have problems, send another message in the Gitter or open a question on Stack Overflow, and tag the question with jhipster. This helps the project to keep the issue tracker clean. Also, Stack Overflow will give your question a larger audience:

srinisubra commented 6 years ago

The issue is because of consul upgrade. I downgraded to consul:0.9.3 and all is well. Thank you

https://github.com/spring-cloud/spring-cloud-consul/issues/365

jdubois commented 6 years ago

Of course, that's why we didn't upgrade...