Spring-cloud-netflix: Application fails due to empty service registry with @EnableZuulProxy

Created on 12 Sep 2017  路  9Comments  路  Source: spring-cloud/spring-cloud-netflix

Application can not start up because of there is not /services node on the zookeeper unless other microservices are started up and connected to zookeeper firstly. I will use docker compose but it try to run each container at the same time. Zuul proxy services can no run in this case.

Caused by: org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /services

Find my exception and dependencies below:

 <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.6.RELEASE</version>
</parent>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-zuul</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
<dependencyManagement>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
        <version>Camden.SR7</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
</dependencyManagement>
proxy_1  | 2017-09-12 15:53:05.746 ERROR 7 --- [           main] o.s.boot.SpringApplication               : Application startup failed
proxy_1  |
proxy_1  | java.lang.reflect.UndeclaredThrowableException: null
proxy_1  |  at org.springframework.util.ReflectionUtils.rethrowRuntimeException(ReflectionUtils.java:317) ~[spring-core-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
proxy_1  |  at org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryClient.getServices(ZookeeperDiscoveryClient.java:109) ~[spring-cloud-zookeeper-discovery-1.0.4.RELEASE.jar!/:1.0.4.RELEASE]
proxy_1  |  at org.springframework.cloud.netflix.zuul.filters.discovery.DiscoveryClientRouteLocator.locateRoutes(DiscoveryClientRouteLocator.java:105) ~[spring-cloud-netflix-core-1.2.7.RELEASE.jar!/:1.2.7.RELEASE]
proxy_1  |  at org.springframework.cloud.netflix.zuul.filters.discovery.DiscoveryClientRouteLocator.locateRoutes(DiscoveryClientRouteLocator.java:43) ~[spring-cloud-netflix-core-1.2.7.RELEASE.jar!/:1.2.7.RELEASE]
proxy_1  |  at org.springframework.cloud.netflix.zuul.filters.SimpleRouteLocator.doRefresh(SimpleRouteLocator.java:152) ~[spring-cloud-netflix-core-1.2.7.RELEASE.jar!/:1.2.7.RELEASE]
proxy_1  |  at org.springframework.cloud.netflix.zuul.filters.discovery.DiscoveryClientRouteLocator.refresh(DiscoveryClientRouteLocator.java:155) ~[spring-cloud-netflix-core-1.2.7.RELEASE.jar!/:1.2.7.RELEASE]
proxy_1  |  at org.springframework.cloud.netflix.zuul.web.ZuulHandlerMapping.setDirty(ZuulHandlerMapping.java:73) ~[spring-cloud-netflix-core-1.2.7.RELEASE.jar!/:1.2.7.RELEASE]
proxy_1  |  at org.springframework.cloud.netflix.zuul.ZuulConfiguration$ZuulRefreshListener.onApplicationEvent(ZuulConfiguration.java:180) ~[spring-cloud-netflix-core-1.2.7.RELEASE.jar!/:1.2.7.RELEASE]
proxy_1  |  at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167) ~[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
proxy_1  |  at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
proxy_1  |  at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393) ~[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
proxy_1  |  at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347) ~[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
proxy_1  |  at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883) ~[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
proxy_1  |  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144) ~[spring-boot-1.5.6.RELEASE.jar!/:1.5.6.RELEASE]
proxy_1  |  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
proxy_1  |  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.6.RELEASE.jar!/:1.5.6.RELEASE]
proxy_1  |  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.6.RELEASE.jar!/:1.5.6.RELEASE]
proxy_1  |  at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.6.RELEASE.jar!/:1.5.6.RELEASE]
proxy_1  |  at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.6.RELEASE.jar!/:1.5.6.RELEASE]
proxy_1  |  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.6.RELEASE.jar!/:1.5.6.RELEASE]
proxy_1  |  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.6.RELEASE.jar!/:1.5.6.RELEASE]
proxy_1  |  at com.XXX.XXX.XXX.XXX.App.main(App.java:25) [classes!/:1.0.0]
proxy_1  |  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_111]
proxy_1  |  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_111]
proxy_1  |  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_111]
proxy_1  |  at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_111]
proxy_1  |  at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [aegon-XXX-proxy.jar:1.0.0]
proxy_1  |  at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [aegon-XXX-proxy.jar:1.0.0]
proxy_1  |  at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [aegon-XXX-proxy.jar:1.0.0]
proxy_1  |  at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [aegon-XXX-proxy.jar:1.0.0]
proxy_1  | Caused by: org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /services
proxy_1  |  at org.apache.zookeeper.KeeperException.create(KeeperException.java:111) ~[zookeeper-3.4.6.jar!/:3.4.6-1569965]
proxy_1  |  at org.apache.zookeeper.KeeperException.create(KeeperException.java:51) ~[zookeeper-3.4.6.jar!/:3.4.6-1569965]
proxy_1  |  at org.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:1590) ~[zookeeper-3.4.6.jar!/:3.4.6-1569965]
proxy_1  |  at org.apache.curator.framework.imps.GetChildrenBuilderImpl$3.call(GetChildrenBuilderImpl.java:214) ~[curator-framework-2.10.0.jar!/:na]
proxy_1  |  at org.apache.curator.framework.imps.GetChildrenBuilderImpl$3.call(GetChildrenBuilderImpl.java:203) ~[curator-framework-2.10.0.jar!/:na]
proxy_1  |  at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:108) ~[curator-client-2.10.0.jar!/:na]
proxy_1  |  at org.apache.curator.framework.imps.GetChildrenBuilderImpl.pathInForeground(GetChildrenBuilderImpl.java:200) ~[curator-framework-2.10.0.jar!/:na]
proxy_1  |  at org.apache.curator.framework.imps.GetChildrenBuilderImpl.forPath(GetChildrenBuilderImpl.java:191) ~[curator-framework-2.10.0.jar!/:na]
proxy_1  |  at org.apache.curator.framework.imps.GetChildrenBuilderImpl.forPath(GetChildrenBuilderImpl.java:38) ~[curator-framework-2.10.0.jar!/:na]
proxy_1  |  at org.apache.curator.x.discovery.details.ServiceDiscoveryImpl.queryForNames(ServiceDiscoveryImpl.java:281) ~[curator-x-discovery-2.10.0.jar!/:na]
proxy_1  |  at org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryClient.getServices(ZookeeperDiscoveryClient.java:106) ~[spring-cloud-zookeeper-discovery-1.0.4.RELEASE.jar!/:1.0.4.RELEASE]
proxy_1  |  ... 28 common frames omitted
proxy_1  |
proxy_1  | 2017-09-12 15:53:05.749  INFO 7 --- [           main] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7d9d1a19: startup date [Tue Sep 12 15:52:58 UTC 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@1c4af82c
proxy_1  | 2017-09-12 15:53:05.751  INFO 7 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase 2147483647
proxy_1  | 2017-09-12 15:53:05.753  INFO 7 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase 0
proxy_1  | 2017-09-12 15:53:05.757  INFO 7 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

Most helpful comment

Indeed

All 9 comments

I'm unsure if this is a problem with spring cloud netflix or spring cloud zookeeper.

Throwing NoNodeException is normal behaviour of apache zookeeper library in this case. But I think It should be handled by spring cloud on startup.

I have a similar issue. I have 3 services, all using the same versions of Spring Cloud Zookeeper and configuration for service discovery is the same. One of these services gets this error if it's started before the others. If I start the bad service after the other two, no error. It seems that somewhere, the "good" services are creating the ZK Node for service discovery if it doesn't exist. The one that is failing never creates the ZK Node for service discovery and simply fails because it doesn't exist.

And turns out the failing service is also using Zuul. I'll prepare a test case to demo the problem since I'm seeing the same behavior as @gokhansari but only with components that are using Zuul.

No answers from this? A gateway app running using Zuul should be able to start at any time and discovery deployed services once they become available.

@kmandeville I still think this is a bug in ZookeeperDiscoveryClient

If this is still a bug in ZookeeperDiscoveryClient as you say, why did you close it?

Oh, did you fix it?

Indeed

Was this page helpful?
0 / 5 - 0 ratings