spring-cloud / spring-cloud-netflix

Integration with Netflix OSS components
http://cloud.spring.io/spring-cloud-netflix/
Apache License 2.0
4.87k stars 2.44k forks source link

Eureka server application fails to start with NoClassDefFoundError: com.google.common.cache.CacheBuilder exception #4299

Closed swagatrath closed 1 month ago

swagatrath commented 3 months ago

Eureka server instance fails to start locally with the following exception:-

Caused by: java.lang.NoClassDefFoundError: com/google/common/cache/CacheBuilder at com.netflix.eureka.registry.AbstractInstanceRegistry.<init>(AbstractInstanceRegistry.java:84) ~[eureka-core-2.0.3.jar:2.0.3] at com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl.<init>(PeerAwareInstanceRegistryImpl.java:136) ~[eureka-core-2.0.3.jar:2.0.3] at org.springframework.cloud.netflix.eureka.server.InstanceRegistry.<init>(InstanceRegistry.java:55) ~[spring-cloud-netflix-eureka-server-4.1.3.jar:4.1.3] at org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration.peerAwareInstanceRegistry(EurekaServerAutoConfiguration.java:246) ~[spring-cloud-netflix-eureka-server-4.1.3.jar:4.1.3] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:146) ~[spring-beans-6.1.11.jar:6.1.11] ... 48 common frames omitted Caused by: java.lang.ClassNotFoundException: com.google.common.cache.CacheBuilder at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na] at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) ~[na:na] ... 55 common frames omitted

Steps:-

  1. Configure a simple eureka server project at spring initializr with:

    • Maven
    • Java 22
    • v 3.3.2
    • Dependencies - Eureka server
  2. Import in IntelliJ and add properties: spring.application.name=eureka-server server.port=8761 eureka.instance.hostname=localhost eureka.client.fetch-registry=false eureka.client.register-with-eureka=false

  3. Start the application and notice it fails due to the above exception

Note - The issue is not observed if I change the spring-cloud.version from 2023.0.3 to 2023.0.2 in pom.xml.

OlgaMaciaszek commented 1 month ago

Hello @swagatrath, thanks fro reporting the issue. Please provide a minimal, complete, verifiable example that reproduces the issue.

spring-cloud-issues commented 1 month ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-cloud-issues commented 1 month ago

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.