3
respostas

[Bug] Erro ao subir Eureka Server

[32m :: Spring Boot :: [39m [2m (v2.7.9)[0;39m

[2m2023-03-05 15:43:48.864[0;39m [32m INFO[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mb.c.a.server.AlurafoodServerApplication [0;39m [2m:[0;39m Starting AlurafoodServerApplication using Java 17.0.5 on deepblue with PID 14418 (/home/cleyton/Documents/workspace-spring-tool-suite-4-4.17.1.RELEASE/alurafood-server/target/classes started by cleyton in /home/cleyton/Documents/workspace-spring-tool-suite-4-4.17.1.RELEASE/alurafood-server) [2m2023-03-05 15:43:48.866[0;39m [32m INFO[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mb.c.a.server.AlurafoodServerApplication [0;39m [2m:[0;39m No active profile set, falling back to 1 default profile: "default" [2m2023-03-05 15:43:49.374[0;39m [32m INFO[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.cloud.context.scope.GenericScope [0;39m [2m:[0;39m BeanFactory id=28945a94-2193-39d1-a208-4637c4934d2d [2m2023-03-05 15:43:49.513[0;39m [32m INFO[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat initialized with port(s): 8080 (http) [2m2023-03-05 15:43:49.518[0;39m [32m INFO[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.apache.catalina.core.StandardService [0;39m [2m:[0;39m Starting service [Tomcat] [2m2023-03-05 15:43:49.518[0;39m [32m INFO[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36morg.apache.catalina.core.StandardEngine [0;39m [2m:[0;39m Starting Servlet engine: [Apache Tomcat/9.0.71] [2m2023-03-05 15:43:49.588[0;39m [32m INFO[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/] [0;39m [2m:[0;39m Initializing Spring embedded WebApplicationContext [2m2023-03-05 15:43:49.588[0;39m [32m INFO[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mw.s.c.ServletWebServerApplicationContext[0;39m [2m:[0;39m Root WebApplicationContext: initialization completed in 696 ms [2m2023-03-05 15:43:49.808[0;39m [32m INFO[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.s.j.s.i.a.WebApplicationImpl [0;39m [2m:[0;39m Initiating Jersey application, version 'Jersey: 1.19.4 05/24/2017 03:20 PM' [2m2023-03-05 15:43:49.841[0;39m [32m INFO[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.n.d.provider.DiscoveryJerseyProvider [0;39m [2m:[0;39m Using JSON encoding codec LegacyJacksonJson [2m2023-03-05 15:43:49.842[0;39m [32m INFO[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.n.d.provider.DiscoveryJerseyProvider [0;39m [2m:[0;39m Using JSON decoding codec LegacyJacksonJson [2m2023-03-05 15:43:49.932[0;39m [32m INFO[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.n.d.provider.DiscoveryJerseyProvider [0;39m [2m:[0;39m Using XML encoding codec XStreamXml [2m2023-03-05 15:43:49.932[0;39m [32m INFO[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.n.d.provider.DiscoveryJerseyProvider [0;39m [2m:[0;39m Using XML decoding codec XStreamXml [2m2023-03-05 15:43:50.574[0;39m [32m INFO[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mDiscoveryClientOptionalArgsConfiguration[0;39m [2m:[0;39m Eureka HTTP Client uses Jersey [2m2023-03-05 15:43:50.604[0;39m [33m WARN[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36miguration$LoadBalancerCaffeineWarnLogger[0;39m [2m:[0;39m Spring Cloud LoadBalancer is currently working with the default cache. While this cache implementation is useful for development and tests, it's recommended to use Caffeine cache in production.You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath. [2m2023-03-05 15:43:50.614[0;39m [32m INFO[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.c.n.eureka.InstanceInfoFactory [0;39m [2m:[0;39m Setting initial instance status as: STARTING [2m2023-03-05 15:43:50.634[0;39m [32m INFO[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m Initializing Eureka in region us-east-1 [2m2023-03-05 15:43:50.638[0;39m [33m WARN[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m

3 respostas

023-03-05 15:43:50.638[0;39m [33m WARN[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mConfigServletWebServerApplicationContext[0;39m [2m:[0;39m Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.netflix.eureka.server.EurekaServerInitializerConfiguration': Unsatisfied dependency expressed through field 'eurekaServerBootstrap'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eurekaServerBootstrap' defined in class path resource [org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfiguration.class]: Unsatisfied dependency expressed through method 'eurekaServerBootstrap' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'peerAwareInstanceRegistry' defined in class path resource [org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.eureka.registry.PeerAwareInstanceRegistry]: Factory method 'peerAwareInstanceRegistry' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.eurekaClient' defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.discovery.EurekaClient]: Factory method 'eurekaClient' threw exception; nested exception is java.lang.RuntimeException: Failed to initialize DiscoveryClient! [2m2023-03-05 15:43:50.643[0;39m [32m INFO[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.apache.catalina.core.StandardService [0;39m [2m:[0;39m Stopping service [Tomcat] [2m2023-03-05 15:43:50.657[0;39m [32m INFO[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mConditionEvaluationReportLoggingListener[0;39m [2m:[0;39m

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. [2m2023-03-05 15:43:50.671[0;39m [31mERROR[0;39m [35m14418[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.boot.SpringApplication [0;39m [2m:[0;39m Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.netflix.eureka.server.EurekaServerInitializerConfiguration': Unsatisfied dependency expressed through field 'eurekaServerBootstrap'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eurekaServerBootstrap' defined in class path resource [org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfiguration.class]: Unsatisfied dependency expressed through method 'eurekaServerBootstrap' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'peerAwareInstanceRegistry' defined in class path resource [org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.eureka.registry.PeerAwareInstanceRegistry]: Factory method 'peerAwareInstanceRegistry' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.eurekaClient' defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.discovery.EurekaClient]: Factory method 'eurekaClient' threw exception; nested exception is java.lang.RuntimeException: Failed to initialize DiscoveryClient! at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:660) ~[spring-beans-5.3.25.jar:5.3.25] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.3.25.jar:5.3.25]

meu pom.xml

4.0.0 org.springframework.boot spring-boot-starter-parent 2.7.9 br.com.alurafood alurafood-server 1.0.0 alurafood-server Eureka Server <java.version>17</java.version> <spring-cloud.version>2021.0.5</spring-cloud.version>

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

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

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        <!-- 
        <version>3.1.4</version>
        -->
    </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>

Olá, Cleyton! Tudo bem?

Pelo log parece um erro na inicialização do contexto de aplicação do Spring. Mais especificamente, o erro ocorreu ao criar o bean org.springframework.cloud.netflix.eureka.server.EurekaServerInitializerConfiguration. O erro está relacionado a uma dependência não satisfeita que é o eurekaServerBootstrap. O erro é causado por uma exceção que ocorreu ao tentar criar o bean peerAwareInstanceRegistry, que por sua vez é usado como argumento para a criação do eurekaServerBootstrap. Essa exceção foi lançada porque ocorreu um erro na criação do bean scopedTarget.eurekaClient. Por fim, a exceção foi causada por uma falha ao tentar inicializar o DiscoveryClient.

Para obter mais informações sobre o erro, o log recomenda executar o aplicativo novamente com o modo de DEBUG habilitado. É possível que um log de depuração possa fornecer mais informações sobre a causa raiz do problema.