My service "app-name" shuts down unexpectedly right after being discovered by the eureka server. Note: app-name or \<app-name> are placeholders in the logs below
At that time right before the shutdown
- The eureka server is running on port 8761 (I can access it)
- The service has been successfully discovered by the eureka server (registration status:
204,registering application with eureka with status UP) - The discovered app has fully started on port 9100 (
Started <app-name> in 7.427 seconds (JVM running for 7.999) - The discovered app runs fine if I don't include eureka discovery
This problem is similar to issue 2281
I am using spring-boot-starter-parent version 2.0.0.M7 and spring-cloudversionFinchley.M5For some reason the propertyeureka.client.healtcheck.enabledis not recognized but the logs tell me the status of the eureka server isUP`
I am getting exactly the same problem when I try the discovery with a very simple demo app right out of spring initializr.
Here is the java implementation
//Eureka server
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
//Discovered service
@SpringBootApplication
@EnableDiscoveryClient
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
The application.properties (or bootstrap.properties)
# properties for discovered service
spring.application.name=<app-name>
spring.profiles.active=default
spring.cloud.config.uri=http://localhost:8888
server.port=9100
eureka.client.service-url.default-zone=http://localhost:8761/
# I also tried eureka.client.service-url.default-zone=http://localhost:8761/eureka
# properties for eureka
spring.application.name=symphony-nlp-eureka-server
server.port=8761
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
Here are the logs
Logs from discovered service
// Service LOGS
2018-01-30 09:25:17.222 INFO [restartedMain] [ConfigServicePropertySourceLocator] Fetching config from server at: http://localhost:8888
2018-01-30 09:25:17.387 INFO [restartedMain] [ConfigServicePropertySourceLocator] Located environment: name=<app-name>, profiles=[default], label=null, version=null, state=null
2018-01-30 09:25:17.387 INFO [restartedMain] [PropertySourceBootstrapConfiguration] Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='classpath:/<app-name>.yml'}]}
2018-01-30 09:25:17.394 INFO [restartedMain] [<app-name>] The following profiles are active: default
2018-01-30 09:25:17.405 INFO [restartedMain] [AnnotationConfigServletWebServerApplicationContext] Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@14f7cee: startup date [Tue Jan 30 09:25:17 GMT 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@121507b
2018-01-30 09:25:18.802 INFO [restartedMain] [DefaultListableBeanFactory] Overriding bean definition for bean 'environmentWebEndpointExtension' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.actuate.autoconfigure.env.EnvironmentEndpointAutoConfiguration; factoryMethodName=environmentWebEndpointExtension; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/actuate/autoconfigure/env/EnvironmentEndpointAutoConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.autoconfigure.LifecycleMvcEndpointAutoConfiguration; factoryMethodName=environmentWebEndpointExtension; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/autoconfigure/LifecycleMvcEndpointAutoConfiguration.class]]
2018-01-30 09:25:19.020 INFO [restartedMain] [GenericScope] BeanFactory id=270e5605-a6fb-3ddf-90f9-1ab7f8277113
2018-01-30 09:25:19.031 INFO [restartedMain] [AutowiredAnnotationBeanPostProcessor] JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-01-30 09:25:19.062 INFO [restartedMain] [PostProcessorRegistrationDelegate$BeanPostProcessorChecker] Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$69f84f5b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-01-30 09:25:19.118 INFO [restartedMain] [ValidatorFactoryImpl] HV000238: Temporal validation tolerance set to 0.
2018-01-30 09:25:19.437 INFO [restartedMain] [TomcatWebServer] Tomcat initialized with port(s): 9100 (http)
2018-01-30 09:25:19.447 INFO [restartedMain] [StandardService] Starting service [Tomcat]
2018-01-30 09:25:19.447 INFO [restartedMain] [StandardEngine] Starting Servlet Engine: Apache Tomcat/8.5.23
2018-01-30 09:25:19.454 INFO [localhost-startStop-1] [AprLifecycleListener] The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: <listing the java path>
2018-01-30 09:25:19.575 INFO [localhost-startStop-1] [[/]] Initializing Spring embedded WebApplicationContext
2018-01-30 09:25:19.576 INFO [localhost-startStop-1] [ContextLoader] Root WebApplicationContext: initialization completed in 2171 ms
2018-01-30 09:25:19.903 INFO [localhost-startStop-1] [RequestMappingHandlerMapping] Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-01-30 09:25:19.903 INFO [localhost-startStop-1] [RequestMappingHandlerMapping] Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-01-30 09:25:19.969 INFO [localhost-startStop-1] [SimpleUrlHandlerMapping] Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-30 09:25:19.969 INFO [localhost-startStop-1] [SimpleUrlHandlerMapping] Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-30 09:25:19.998 INFO [localhost-startStop-1] [SimpleUrlHandlerMapping] Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-30 09:25:20.742 INFO [localhost-startStop-1] [WebMvcEndpointHandlerMapping] Mapped "{[/actuator/health],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-01-30 09:25:20.743 INFO [localhost-startStop-1] [WebMvcEndpointHandlerMapping] Mapped "{[/actuator/info],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-01-30 09:25:20.743 INFO [localhost-startStop-1] [WebMvcEndpointHandlerMapping] Mapped "{[/actuator],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto private java.util.Map<java.lang.String, java.util.Map<java.lang.String, org.springframework.boot.actuate.endpoint.web.Link>> org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.links(javax.servlet.http.HttpServletRequest)
2018-01-30 09:25:20.805 INFO [localhost-startStop-1] [ServletRegistrationBean] Mapping servlet: 'dispatcherServlet' to [/]
2018-01-30 09:25:20.809 INFO [localhost-startStop-1] [FilterRegistrationBean] Mapping filter: 'webMetricsFilter' to: [/*]
2018-01-30 09:25:20.809 INFO [localhost-startStop-1] [FilterRegistrationBean] Mapping filter: 'characterEncodingFilter' to: [/*]
2018-01-30 09:25:20.809 INFO [localhost-startStop-1] [FilterRegistrationBean] Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-01-30 09:25:20.810 INFO [localhost-startStop-1] [FilterRegistrationBean] Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-01-30 09:25:20.810 INFO [localhost-startStop-1] [FilterRegistrationBean] Mapping filter: 'requestContextFilter' to: [/*]
2018-01-30 09:25:20.810 INFO [localhost-startStop-1] [FilterRegistrationBean] Mapping filter: 'webRequestLoggingFilter' to: [/*]
2018-01-30 09:25:20.838 INFO [restartedMain] [MessageBroker] creating message broker
2018-01-30 09:25:22.197 INFO [restartedMain] [Authentication] Successfully retrieved tokens
2018-01-30 09:25:22.399 WARN [restartedMain] [URLConfigurationSource] No URLs will be polled as dynamic configuration sources.
2018-01-30 09:25:22.399 INFO [restartedMain] [URLConfigurationSource] To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2018-01-30 09:25:22.404 WARN [restartedMain] [URLConfigurationSource] No URLs will be polled as dynamic configuration sources.
2018-01-30 09:25:22.404 INFO [restartedMain] [URLConfigurationSource] To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2018-01-30 09:25:22.445 INFO [restartedMain] [ValidatorFactoryImpl] HV000238: Temporal validation tolerance set to 0.
2018-01-30 09:25:22.518 INFO [restartedMain] [RequestMappingHandlerAdapter] Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@14f7cee: startup date [Tue Jan 30 09:25:17 GMT 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@121507b
2018-01-30 09:25:22.818 WARN [restartedMain] [OptionalLiveReloadServer] Unable to start LiveReload server
2018-01-30 09:25:23.020 INFO [restartedMain] [AnnotationMBeanExporter] Registering beans for JMX exposure on startup
2018-01-30 09:25:23.028 INFO [restartedMain] [AnnotationMBeanExporter] Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2018-01-30 09:25:23.029 INFO [restartedMain] [AnnotationMBeanExporter] Bean with name 'environmentManager' has been autodetected for JMX exposure
2018-01-30 09:25:23.030 INFO [restartedMain] [AnnotationMBeanExporter] Bean with name 'refreshScope' has been autodetected for JMX exposure
2018-01-30 09:25:23.031 INFO [restartedMain] [AnnotationMBeanExporter] Located managed bean 'environmentManager': registering with JMX server as MBean [org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager]
2018-01-30 09:25:23.038 INFO [restartedMain] [AnnotationMBeanExporter] Located managed bean 'refreshScope': registering with JMX server as MBean [org.springframework.cloud.context.scope.refresh:name=refreshScope,type=RefreshScope]
2018-01-30 09:25:23.048 INFO [restartedMain] [AnnotationMBeanExporter] Located managed bean 'configurationPropertiesRebinder': registering with JMX server as MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=14f7cee,type=ConfigurationPropertiesRebinder]
2018-01-30 09:25:23.088 INFO [restartedMain] [DefaultLifecycleProcessor] Starting beans in phase 0
2018-01-30 09:25:23.094 INFO [restartedMain] [InstanceInfoFactory] Setting initial instance status as: STARTING
2018-01-30 09:25:23.128 INFO [restartedMain] [DiscoveryClient] Initializing Eureka in region us-east-1
2018-01-30 09:25:23.164 INFO [restartedMain] [DiscoveryJerseyProvider] Using JSON encoding codec LegacyJacksonJson
2018-01-30 09:25:23.164 INFO [restartedMain] [DiscoveryJerseyProvider] Using JSON decoding codec LegacyJacksonJson
2018-01-30 09:25:23.230 INFO [restartedMain] [DiscoveryJerseyProvider] Using XML encoding codec XStreamXml
2018-01-30 09:25:23.230 INFO [restartedMain] [DiscoveryJerseyProvider] Using XML decoding codec XStreamXml
2018-01-30 09:25:23.360 INFO [restartedMain] [ConfigClusterResolver] Resolving eureka endpoints via configuration
2018-01-30 09:25:23.393 INFO [restartedMain] [DiscoveryClient] Disable delta property : false
2018-01-30 09:25:23.393 INFO [restartedMain] [DiscoveryClient] Single vip registry refresh property : null
2018-01-30 09:25:23.393 INFO [restartedMain] [DiscoveryClient] Force full registry fetch : false
2018-01-30 09:25:23.393 INFO [restartedMain] [DiscoveryClient] Application is null : false
2018-01-30 09:25:23.393 INFO [restartedMain] [DiscoveryClient] Registered Applications size is zero : true
2018-01-30 09:25:23.393 INFO [restartedMain] [DiscoveryClient] Application version is -1: true
2018-01-30 09:25:23.393 INFO [restartedMain] [DiscoveryClient] Getting all instance registry info from the eureka server
2018-01-30 09:25:23.434 INFO [restartedMain] [DiscoveryClient] The response status is 200
2018-01-30 09:25:23.435 INFO [restartedMain] [DiscoveryClient] Starting heartbeat executor: renew interval is: 30
2018-01-30 09:25:23.436 INFO [restartedMain] [InstanceInfoReplicator] InstanceInfoReplicator onDemand update allowed rate per min is 4
2018-01-30 09:25:23.439 INFO [restartedMain] [DiscoveryClient] Discovery Client initialized at timestamp 1517304323439 with initial instances count: 0
2018-01-30 09:25:23.442 INFO [restartedMain] [EurekaServiceRegistry] Registering application <app-name> with eureka with status UP
2018-01-30 09:18:53.450 INFO [restartedMain] [Http11NioProtocol] Initializing ProtocolHandler ["http-nio-9100"]
2018-01-30 09:18:53.453 INFO [DiscoveryClient-InstanceInfoReplicator-0] [DiscoveryClient] DiscoveryClient_<app-name>/<host>:<app-name>:9100 - registration status: 204
2018-01-30 09:18:53.457 INFO [restartedMain] [Http11NioProtocol] Starting ProtocolHandler ["http-nio-9100"]
2018-01-30 09:18:53.464 INFO [restartedMain] [NioSelectorPool] Using a shared selector for servlet write/read
2018-01-30 09:18:53.486 INFO [restartedMain] [TomcatWebServer] Tomcat started on port(s): 9100 (http) with context path ''
2018-01-30 09:18:53.487 INFO [restartedMain] [EurekaAutoServiceRegistration] Updating port to 9100
2018-01-30 09:18:53.490 INFO [restartedMain] [<app-name>] Started <app-name> in 7.427 seconds (JVM running for 7.999)
2018-01-30 09:18:53.524 WARN [restartedMain] [DiscoveryClient] Saw local status change event StatusChangeEvent [timestamp=1517303933524, current=DOWN, previous=UP]
2018-01-30 09:18:53.524 INFO [DiscoveryClient-InstanceInfoReplicator-0] [DiscoveryClient] DiscoveryClient_<app-name>/<host>:<app-name>:9100: registering service...
2018-01-30 09:18:53.535 INFO [restartedMain] [DiscoveryClient] Shutting down DiscoveryClient ...
2018-01-30 09:18:53.536 INFO [restartedMain] [DiscoveryClient] Unregistering ...
2018-01-30 09:18:53.538 INFO [DiscoveryClient-InstanceInfoReplicator-0] [DiscoveryClient] DiscoveryClient_<app-name>/<host>:<app-name>:9100 - registration status: 204
2018-01-30 09:18:53.542 INFO [restartedMain] [DiscoveryClient] DiscoveryClient_<app-name>/<host>:<app-name>:9100 - deregister status: 200
2018-01-30 09:18:53.549 INFO [restartedMain] [DiscoveryClient] Completed shut down of DiscoveryClient
Logs from eureka server
2018-01-30 09:18:15.373 INFO 10804 --- [nio-8761-exec-8] c.n.e.registry.AbstractInstanceRegistry : Registered instance <app-name>/<host>:<app-name>:9100 with status UP (replication=false)
2018-01-30 09:18:15.383 INFO 10804 --- [nio-8761-exec-9] c.n.e.registry.AbstractInstanceRegistry : Registered instance <app-name>/<host>:<app-name>:9100 with status DOWN (replication=false)
2018-01-30 09:18:15.400 INFO 10804 --- [io-8761-exec-10] c.n.e.registry.AbstractInstanceRegistry : Cancelled instance <app-name>/<host>:<app-name>:9100 (replication=false)
2018-01-30 09:18:15.976 INFO 10804 --- [nio-8761-exec-2] c.n.e.registry.AbstractInstanceRegistry : Registered instance <app-name>/<host>:<app-name>:9100 with status DOWN (replication=true)
2018-01-30 09:18:15.977 INFO 10804 --- [nio-8761-exec-2] c.n.e.registry.AbstractInstanceRegistry : Cancelled instance <app-name>/<host>:<app-name>:9100 (replication=true)
2018-01-30 09:18:46.854 INFO 10804 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0ms
Thanks for the help
Comment From: ryanjbaxter
Instead of pasting the code in the issue can you provide the actual projects via a git repo or zip file?
Comment From: alalicon577
I got the same problem. I resolved it by adding this dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Comment From: padmano
@alalicon577's solution worked. I had the same issue.
Probably here https://cloud.spring.io/spring-cloud-netflix/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter it has to be updated to add
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
also to the eureka client project.
Comment From: YKG
@alalicon577 Thanks!
Comment From: karthiknsiva
@alalicon577 Thank you! The solution worked.
Comment From: haiharry26
@alalicon577 Thank you so much. your Suggestion worked and it saved my lot of time. Great. Thank you once again.
Comment From: NandoMejiaa
@alalicon577 Thank you... The solution worked
Comment From: chenpenghui93
@alalicon577 Thanks.
Comment From: trustjalaj
@alalicon577 Thanks for this.It saved my day.
Comment From: mohanreddy-mca
Thank you, above solution worked....
Comment From: asp314159
I got the same problem even after adding web dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
I am using spring boot version 2.1.6.Release and Greenwich.SR1
Comment From: spencergibb
@asp314159 if you can provide a complete, minimal, verifiable sample that reproduces the problem, please open a new issue. It should be available as a GitHub (or similar) project or attached to the new issue as a zip file.
Comment From: ericmuchiri
add this <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Comment From: jair-anderson-souza
Doesn't worked for me after add web dependency.
Comment From: Yayan89
It worked for me. Great Thanks!! The logs were not very helpful for this one to troubleshoot. So I guess it is mandatory to add starter boot web for all cloud project.
Comment From: SunChestnut
@alalicon577 Thank you so much!!!!
Comment From: Meena-Chowdary
I added web dependency but still i couldnt solve the prolem. My microservice is first getting registered with eureka but soon it is getting cancelled. Registered instance VENDOR-SERVICE/localhost:vendor-service with status UP (replication=false) 2020-05-05 14:00:00.526 INFO 4012 --- [io-8761-exec-10] c.n.e.registry.AbstractInstanceRegistry : Registered instance VENDOR-SERVICE/localhost:vendor-service with status DOWN (replication=false) 2020-05-05 14:00:03.569 INFO 4012 --- [nio-8761-exec-4] c.n.e.registry.AbstractInstanceRegistry : Cancelled instance VENDOR-SERVICE/localhost:vendor-service (replication=false)
Comment From: skone16
I am facing the same issue my microservices are getting deregistered automatically after they registered in eureka. these are my eureka-server properties
Set this only for this sample service without which starting the instance will by default wait for the default of 5 mins
eureka.waitTimeInMsWhenSyncEmpty=0 eureka.disableDelta=false eureka.disableDeltaForRemoteRegions=true
Setup EIP timeouts
eureka.eipBindRebindRetries=5 eureka.eipBindRebindRetryIntervalMs=120000 eureka.server.eviction-interval-timer-in-ms=12000 eureka.server.enableSelfPreservation=false enableSelfPreservation=false renewalPercentThreshold=0.85
after going live:
renewalPercentThreshold=0.85
eureka.eurekaServer.domainName=${aesd.archaius.deployment.domain}
eureka.eurekaServer.context=eureka/v2
eureka.healthCheckUrl=http://${archaius.deployment.serverPrivIP}:8080/eureka/healthcheck
eureka.registration.enabled=true eureka.enableSelfPreservation=true
please let me know if any changes required and what's the solution to fix this ?
Comment From: spencergibb
@skone16 if you can provide a complete, minimal, verifiable sample that reproduces the problem, please open a new issue. It should be available as a GitHub (or similar) project or attached to the new issue as a zip file.
Comment From: skone16
@skone16 if you can provide a complete, minimal, verifiable sample that reproduces the problem, please open a new issue. It should be available as a GitHub (or similar) project or attached to the new issue as a zip file.
sure, thanks