title: Failed to start bean 'eurekaAutoServiceRegistration'
body: <p>I have the following error starting ApplicationContext in my SpringBoot application:</p>
  
  <pre><code>org.springframework.context.ApplicationContextException: Failed to start bean 'eurekaAutoServiceRegistration'; nested exception is java.lang.NullPointerException
  at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
  at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:50) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
  at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:348) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
  at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:151) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
  at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:114) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:880) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
  at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
  at es.ual.acg.cos.abstractcomponents.AbstractcomponentsApplication.main(AbstractcomponentsApplication.java:12) [classes/:na]
  
      Caused by: java.lang.NullPointerException: null
  at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry.maybeInitializeClient(EurekaServiceRegistry.java:56) ~[spring-cloud-netflix-eureka-client-1.4.3.RELEASE.jar:1.4.3.RELEASE]
  at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry.register(EurekaServiceRegistry.java:37) ~[spring-cloud-netflix-eureka-client-1.4.3.RELEASE.jar:1.4.3.RELEASE]
  at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaAutoServiceRegistration.start(EurekaAutoServiceRegistration.java:80) ~[spring-cloud-netflix-eureka-client-1.4.3.RELEASE.jar:1.4.3.RELEASE]
  at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:175) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
  ... 14 common frames omitted
  </code></pre>
  
  <p>I have enabled Eureka Client with decorator <code>@EnableEurekaClient</code> in main class.</p>
  
  <p>And I have configure .properties file with: </p>
  
  <pre><code>eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
  eureka.instance.preferIpAddress=true
  </code></pre>
  
  <p>I use:</p>
  
  <pre><code>&lt;dependency&gt;
          &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
          &lt;artifactId&gt;spring-cloud-starter-netflix-eureka-client&lt;/artifactId&gt;
          &lt;version&gt;1.4.3.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>First of all, I have run Eureka Server in other spring boot project (it works properly).</p>
  
  <p>Note: this is the main class:</p>
  
  <pre><code>package es.ual.acg.cos.abstractcomponents;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
  
  @SpringBootApplication(scanBasePackages={"es.ual.acg.cos.abstractcomponents", "es.ual.acg.cos.util"})
  @EnableEurekaClient
  public class AbstractcomponentsApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(AbstractcomponentsApplication.class, args);
      }
  }
  </code></pre>