title: Spring - service shuts down after being discovered by eureka server
body: <p>My service "app-name" shuts down unexpectedly right after having started.
  At that time</p>
  
  <ul>
  <li>The eureka server is running on port 8761</li>
  <li>The service has been successfully discovered by the eureka server (registration status: <code>204</code>, <code>registering application with eureka with status UP</code>)</li>
  <li>The discovered app has fully started on port 9100 (<code>Started &lt;app-name&gt; in 7.427 seconds (JVM running for 7.999</code>)</li>
  </ul>
  
  <p>If I don't include service discovery the app starts up fine</p>
  
  <p>Here is the java implementation</p>
  
  <pre><code>//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);
      }
  }
  </code></pre>
  
  <p>The <code>application.properties</code> (or <code>bootstrap.properties</code>)</p>
  
  <pre><code># properties for discovered service
  spring.application.name=&lt;app-name&gt;
  spring.profiles.active=default
  spring.cloud.config.uri=http://localhost:8888
  server.port=9100
  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
  </code></pre>
  
  <p>Here are the logs</p>
  
  <p><em>Logs from discovered service</em></p>
  
  <pre><code>// 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=&lt;app-name&gt;, 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:/&lt;app-name&gt;.yml'}]}
  2018-01-30 09:25:17.394 INFO  [restartedMain] [&lt;app-name&gt;] 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: &lt;listing the java path&gt;
  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&lt;java.util.Map&lt;java.lang.String, java.lang.Object&gt;&gt; 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&lt;java.lang.String, java.lang.String&gt;)
  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&lt;java.lang.String, java.lang.String&gt;)
  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&lt;java.lang.String, java.util.Map&lt;java.lang.String, org.springframework.boot.actuate.endpoint.web.Link&gt;&gt; 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 &lt;app-name&gt; 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_&lt;app-name&gt;/&lt;host&gt;:&lt;app-name&gt;: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] [&lt;app-name&gt;] Started &lt;app-name&gt; 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_&lt;app-name&gt;/&lt;host&gt;:&lt;app-name&gt;: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_&lt;app-name&gt;/&lt;host&gt;:&lt;app-name&gt;:9100 - registration status: 204
  2018-01-30 09:18:53.542 INFO  [restartedMain] [DiscoveryClient] DiscoveryClient_&lt;app-name&gt;/&lt;host&gt;:&lt;app-name&gt;:9100 - deregister  status: 200
  2018-01-30 09:18:53.549 INFO  [restartedMain] [DiscoveryClient] Completed shut down of DiscoveryClient
  </code></pre>
  
  <p><em>Logs from eureka server</em></p>
  
  <pre><code>2018-01-30 09:18:15.373  INFO 10804 --- [nio-8761-exec-8] c.n.e.registry.AbstractInstanceRegistry  : Registered instance &lt;app-name&gt;/&lt;host&gt;:&lt;app-name&gt;: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 &lt;app-name&gt;/&lt;host&gt;:&lt;app-name&gt;: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 &lt;app-name&gt;/&lt;host&gt;:&lt;app-name&gt;:9100 (replication=false)
  2018-01-30 09:18:15.976  INFO 10804 --- [nio-8761-exec-2] c.n.e.registry.AbstractInstanceRegistry  : Registered instance &lt;app-name&gt;/&lt;host&gt;:&lt;app-name&gt;: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 &lt;app-name&gt;/&lt;host&gt;:&lt;app-name&gt;: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
  </code></pre>
  
  <p>Thanks for the help</p>