0

I am not able to run the spring eureka server, I do get the following error.

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration': Unsatisfied dependency expressed through field 'optionalArgs'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'discoveryClientOptionalArgs' defined in class path resource [org/springframework/cloud/netflix/eureka/config/DiscoveryClientOptionalArgsConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.NoClassDefFoundError: com/netflix/eventbus/spi/EventBus at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]

Below is the my code which runs in my mac machine perfectly, But the same is not working in my windows machine and was not able to find out the solution for it I reinstalled sts tool suite, eclipse everything still the same error persists

MyApplication.java

package com.example.microservice;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@EnableEurekaServer
@SpringBootApplication
public class MicroserviceApplication {

   public static void main(String[] args) {
       SpringApplication.run(MicroserviceApplication.class, args);
   }
}

application.yml

server:
    port: 8000

eureka:
   client:
       register-with-eureka: false
       fetch-registry: false

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>microservice</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>microservice</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <spring-cloud.version>Edgware.RELEASE</spring-cloud.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-eureka-server</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>


</project>

Only in my windows machine it is not working and its throwing the above issue which I have mentioned?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Balaji Gopal
  • 789
  • 1
  • 6
  • 13

1 Answers1

2

As per the error below, your project is missing a jar file

java.lang.NoClassDefFoundError: com/netflix/eventbus/spi/EventBus 

Have you tried by including netflix-eventbus jar file in your pom?

amdg
  • 2,211
  • 1
  • 14
  • 25
  • Hey @amdg The issue got solved after I installed the eventBus pom but Now I am unble to start the app, I do get the below error 2017-12-01 16:44:22.925 INFO 13480 --- [ main] c.e.m.MicroserviceApplication : Started MicroserviceApplication in 7.888 seconds (JVM running for 8.413) 2017-12-01 16:44:24.678 ERROR 13480 --- [nfoReplicator-0] c.n.d.s.t.d.RedirectingEurekaHttpClient : Request execution error com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect – Balaji Gopal Dec 01 '17 at 11:16
  • Is your registry running? It will fail otherwise. – amdg Dec 01 '17 at 12:05
  • I am running the eureka server itself not the client, so once eureka server is up then only registry problems will occur right if I am not wrong. – Balaji Gopal Dec 01 '17 at 12:32
  • Hey, looks like some problem with your configuration. – amdg Dec 04 '17 at 04:33