It seems that there is some issue because of changes from df9e581 made for #4176
With last 2022.0.3-SNAPSHOT build:
09:24:40.416 INFO [ main] com.netflix.discovery.DiscoveryClient : DiscoveryClient_XXXX/YYYY - was unable to refresh its cache! This periodic background refresh will be retried in 30 seconds. status = jakarta/ws/rs/core/Response$Status stacktrace = java.lang.NoClassDefFoundError: jakarta/ws/rs/core/Response$Status
at com.netflix.discovery.DiscoveryClient.getAndStoreFullRegistry(DiscoveryClient.java:1047)
at com.netflix.discovery.DiscoveryClient.fetchRegistry(DiscoveryClient.java:958)
at com.netflix.discovery.DiscoveryClient.<init>(DiscoveryClient.java:396)
at com.netflix.discovery.DiscoveryClient.<init>(DiscoveryClient.java:247)
at com.netflix.discovery.DiscoveryClient.<init>(DiscoveryClient.java:242)
at org.springframework.cloud.netflix.eureka.CloudEurekaClient.<init>(CloudEurekaClient.java:68)
at org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.eurekaClient(EurekaClientAutoConfiguration.java:320)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:139)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:647)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1332)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1162)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$1(AbstractBeanFactory.java:365)
at org.springframework.cloud.context.scope.GenericScope$BeanLifecycleWrapper.getBean(GenericScope.java:375)
at org.springframework.cloud.context.scope.GenericScope.get(GenericScope.java:179)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:362)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35)
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration.getTargetObject(EurekaRegistration.java:128)
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration.getEurekaClient(EurekaRegistration.java:116)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:281)
at org.springframework.cloud.context.scope.GenericScope$LockedScopedProxyFactoryBean.invoke(GenericScope.java:482)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:702)
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration$$SpringCGLIB$$0.getEurekaClient(<generated>)
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry.maybeInitializeClient(EurekaServiceRegistry.java:54)
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry.register(EurekaServiceRegistry.java:38)
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaAutoServiceRegistration.start(EurekaAutoServiceRegistration.java:83)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:958)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:611)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:733)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:435)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1305)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1294)
at org.nth.messaging.core.Application.main(Application.java:117)
Caused by: java.lang.ClassNotFoundException: jakarta.ws.rs.core.Response$Status
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 53 more
09:24:40.742 WARN [DiscoveryClient-InstanceInfoReplicator-0] c.n.discovery.InstanceInfoReplicator : There was a problem with the instance info replicator
java.lang.NoClassDefFoundError: jakarta/ws/rs/core/Response$Status
at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:828)
at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:121)
at com.netflix.discovery.InstanceInfoReplicator$1.run(InstanceInfoReplicator.java:101)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ClassNotFoundException: jakarta.ws.rs.core.Response$Status
... 9 common frames omitted
09:29:21.156 ERROR [DiscoveryClient-HeartbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_XXX/YYY - was unable to send heartbeat!
java.lang.NoClassDefFoundError: jakarta/ws/rs/core/Response$Status
at com.netflix.discovery.DiscoveryClient.renew(DiscoveryClient.java:839)
at com.netflix.discovery.DiscoveryClient$HeartbeatThread.run(DiscoveryClient.java:1401)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ClassNotFoundException: jakarta.ws.rs.core.Response$Status
... 7 common frames omitted
I have tried to add 'jakarta.ws.rs:jakarta.ws.rs-api' dependency but then application won't start at all:
09:31:53.078 WARN [ main] o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration': Unsatisfied dependency expressed through field 'optionalArgs': No qualifying bean of type 'com.netflix.discovery.AbstractDiscoveryClientOptionalArgs<?>' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
09:31:53.198 ERROR [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field optionalArgs in org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration required a bean of type 'com.netflix.discovery.AbstractDiscoveryClientOptionalArgs' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Sample to reproduce with Spring Boot 3.1.0 is at https://github.com/ztomic/spring-cloud-netflix-issue
discovery-server
is Eureka server
microservice-2022-0-2
is Eureka client with Spring Cloud 2022.0.2
microservice-2022-0-3
is Eureka client with Spring Cloud 2022.0.3-SNAPSHOT
You can run all of them, microservice-2022-0-3
will log errors and warnings mentioned above. microservice-2022-0-2
will run normally.
Comment From: spencergibb
Which app has that error?
Comment From: ztomic
microservice-2022-0-3
Comment From: ztomic
`microservice-2022-0-2` log (working OK):
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.1.0)
2023-05-23T16:16:02.476+02:00 INFO 36352 --- [ main] c.e.m.Microservice202202Application : Starting Microservice202202Application using Java 19.0.2 with PID 36352 (C:\Users\ztomic\NTH\git\demo\spring-cloud-example\microservice-2022-0-2\target\classes started by ztomic in C:\Users\ztomic\NTH\git\demo\spring-cloud-example\microservice-2022-0-2)
2023-05-23T16:16:02.479+02:00 INFO 36352 --- [ main] c.e.m.Microservice202202Application : No active profile set, falling back to 1 default profile: "default"
2023-05-23T16:16:03.286+02:00 INFO 36352 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=5a195a13-4038-3503-a8a4-f904849a4c72
2023-05-23T16:16:03.518+02:00 INFO 36352 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9801 (http)
2023-05-23T16:16:03.528+02:00 INFO 36352 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-05-23T16:16:03.528+02:00 INFO 36352 --- [ main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.8]
2023-05-23T16:16:03.602+02:00 INFO 36352 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-05-23T16:16:03.602+02:00 INFO 36352 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1082 ms
2023-05-23T16:16:05.738+02:00 INFO 36352 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2023-05-23T16:16:07.639+02:00 INFO 36352 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2023-05-23T16:16:07.645+02:00 INFO 36352 --- [ main] DiscoveryClientOptionalArgsConfiguration : Eureka HTTP Client uses RestTemplate.
2023-05-23T16:16:07.666+02:00 WARN 36352 --- [ main] iguration$LoadBalancerCaffeineWarnLogger : 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.
2023-05-23T16:16:07.670+02:00 INFO 36352 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 1 endpoint(s) beneath base path '/actuator'
2023-05-23T16:16:07.715+02:00 INFO 36352 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2023-05-23T16:16:07.742+02:00 INFO 36352 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2023-05-23T16:16:07.760+02:00 INFO 36352 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2023-05-23T16:16:07.779+02:00 INFO 36352 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2023-05-23T16:16:07.779+02:00 INFO 36352 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2023-05-23T16:16:07.779+02:00 INFO 36352 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2023-05-23T16:16:07.779+02:00 INFO 36352 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false
2023-05-23T16:16:07.779+02:00 INFO 36352 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2023-05-23T16:16:07.779+02:00 INFO 36352 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2023-05-23T16:16:07.779+02:00 INFO 36352 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2023-05-23T16:16:08.191+02:00 INFO 36352 --- [ main] com.netflix.discovery.DiscoveryClient : The response status is 200
2023-05-23T16:16:08.193+02:00 INFO 36352 --- [ main] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 5
2023-05-23T16:16:08.194+02:00 INFO 36352 --- [ main] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2023-05-23T16:16:08.198+02:00 INFO 36352 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1684851368197 with initial instances count: 0
2023-05-23T16:16:08.199+02:00 INFO 36352 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application MICROSERVICE-2022-0-2 with eureka with status UP
2023-05-23T16:16:08.200+02:00 INFO 36352 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1684851368200, current=UP, previous=STARTING]
2023-05-23T16:16:08.201+02:00 INFO 36352 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MICROSERVICE-2022-0-2/microservice-2022-0-2-01: registering service...
2023-05-23T16:16:08.215+02:00 INFO 36352 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9801 (http) with context path ''
2023-05-23T16:16:08.215+02:00 INFO 36352 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 9801
2023-05-23T16:16:08.286+02:00 INFO 36352 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MICROSERVICE-2022-0-2/microservice-2022-0-2-01 - registration status: 204
2023-05-23T16:16:09.833+02:00 INFO 36352 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2023-05-23T16:16:09.843+02:00 INFO 36352 --- [ main] c.e.m.Microservice202202Application : Started Microservice202202Application in 9.599 seconds (process running for 10.229)
2023-05-23T16:16:10.152+02:00 INFO 36352 --- [-192.168.10.254] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-05-23T16:16:10.152+02:00 INFO 36352 --- [-192.168.10.254] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2023-05-23T16:16:10.153+02:00 INFO 36352 --- [-192.168.10.254] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
`microservice-2022-0-3` log (has isssues):
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.1.0)
2023-05-23T16:16:04.600+02:00 INFO 9872 --- [ main] c.e.m.Microservice202203Application : Starting Microservice202203Application using Java 19.0.2 with PID 9872 (C:\Users\ztomic\NTH\git\demo\spring-cloud-example\microservice-2022-0-3\target\classes started by ztomic in C:\Users\ztomic\NTH\git\demo\spring-cloud-example\microservice-2022-0-3)
2023-05-23T16:16:04.602+02:00 INFO 9872 --- [ main] c.e.m.Microservice202203Application : No active profile set, falling back to 1 default profile: "default"
2023-05-23T16:16:05.297+02:00 INFO 9872 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=ad7baec1-6bf6-371a-a11a-bd10737b9903
2023-05-23T16:16:05.492+02:00 INFO 9872 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9802 (http)
2023-05-23T16:16:05.499+02:00 INFO 9872 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-05-23T16:16:05.499+02:00 INFO 9872 --- [ main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.8]
2023-05-23T16:16:05.576+02:00 INFO 9872 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-05-23T16:16:05.576+02:00 INFO 9872 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 937 ms
2023-05-23T16:16:07.670+02:00 INFO 9872 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2023-05-23T16:16:09.503+02:00 INFO 9872 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2023-05-23T16:16:09.510+02:00 INFO 9872 --- [ main] DiscoveryClientOptionalArgsConfiguration : Eureka HTTP Client uses RestTemplate.
2023-05-23T16:16:09.532+02:00 WARN 9872 --- [ main] iguration$LoadBalancerCaffeineWarnLogger : 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.
2023-05-23T16:16:09.537+02:00 INFO 9872 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 1 endpoint(s) beneath base path '/actuator'
2023-05-23T16:16:09.576+02:00 INFO 9872 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2023-05-23T16:16:09.618+02:00 INFO 9872 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2023-05-23T16:16:09.622+02:00 INFO 9872 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2023-05-23T16:16:09.636+02:00 INFO 9872 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2023-05-23T16:16:09.636+02:00 INFO 9872 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2023-05-23T16:16:09.636+02:00 INFO 9872 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2023-05-23T16:16:09.636+02:00 INFO 9872 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false
2023-05-23T16:16:09.636+02:00 INFO 9872 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2023-05-23T16:16:09.637+02:00 INFO 9872 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2023-05-23T16:16:09.637+02:00 INFO 9872 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2023-05-23T16:16:09.879+02:00 INFO 9872 --- [ main] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MICROSERVICE-2022-0-3/microservice-2022-0-3-01 - was unable to refresh its cache! This periodic background refresh will be retried in 30 seconds. status = jakarta/ws/rs/core/Response$Status stacktrace = java.lang.NoClassDefFoundError: jakarta/ws/rs/core/Response$Status
at com.netflix.discovery.DiscoveryClient.getAndStoreFullRegistry(DiscoveryClient.java:1047)
at com.netflix.discovery.DiscoveryClient.fetchRegistry(DiscoveryClient.java:958)
at com.netflix.discovery.DiscoveryClient.<init>(DiscoveryClient.java:396)
at com.netflix.discovery.DiscoveryClient.<init>(DiscoveryClient.java:247)
at com.netflix.discovery.DiscoveryClient.<init>(DiscoveryClient.java:242)
at org.springframework.cloud.netflix.eureka.CloudEurekaClient.<init>(CloudEurekaClient.java:68)
at org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.eurekaClient(EurekaClientAutoConfiguration.java:320)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:139)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:647)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1332)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1162)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$1(AbstractBeanFactory.java:365)
at org.springframework.cloud.context.scope.GenericScope$BeanLifecycleWrapper.getBean(GenericScope.java:375)
at org.springframework.cloud.context.scope.GenericScope.get(GenericScope.java:179)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:362)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35)
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration.getTargetObject(EurekaRegistration.java:128)
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration.getEurekaClient(EurekaRegistration.java:116)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:281)
at org.springframework.cloud.context.scope.GenericScope$LockedScopedProxyFactoryBean.invoke(GenericScope.java:482)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:702)
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration$$SpringCGLIB$$0.getEurekaClient(<generated>)
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry.maybeInitializeClient(EurekaServiceRegistry.java:54)
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry.register(EurekaServiceRegistry.java:38)
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaAutoServiceRegistration.start(EurekaAutoServiceRegistration.java:83)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:958)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:611)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:733)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:435)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1305)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1294)
at com.example.microservicea.Microservice202203Application.main(Microservice202203Application.java:32)
Caused by: java.lang.ClassNotFoundException: jakarta.ws.rs.core.Response$Status
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 49 more
2023-05-23T16:16:09.879+02:00 INFO 9872 --- [ main] com.netflix.discovery.DiscoveryClient : Initial registry fetch from primary servers failed
2023-05-23T16:16:09.879+02:00 WARN 9872 --- [ main] com.netflix.discovery.DiscoveryClient : Using default backup registry implementation which does not do anything.
2023-05-23T16:16:09.879+02:00 INFO 9872 --- [ main] com.netflix.discovery.DiscoveryClient : Initial registry fetch from backup servers failed
2023-05-23T16:16:09.881+02:00 INFO 9872 --- [ main] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 5
2023-05-23T16:16:09.883+02:00 INFO 9872 --- [ main] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2023-05-23T16:16:09.886+02:00 INFO 9872 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1684851369885 with initial instances count: 0
2023-05-23T16:16:09.887+02:00 INFO 9872 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application MICROSERVICE-2022-0-3 with eureka with status UP
2023-05-23T16:16:09.888+02:00 INFO 9872 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1684851369888, current=UP, previous=STARTING]
2023-05-23T16:16:09.889+02:00 INFO 9872 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MICROSERVICE-2022-0-3/microservice-2022-0-3-01: registering service...
2023-05-23T16:16:09.902+02:00 INFO 9872 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9802 (http) with context path ''
2023-05-23T16:16:09.902+02:00 INFO 9872 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 9802
2023-05-23T16:16:09.916+02:00 INFO 9872 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MICROSERVICE-2022-0-3/microservice-2022-0-3-01 - registration status: 204
2023-05-23T16:16:09.916+02:00 WARN 9872 --- [nfoReplicator-0] c.n.discovery.InstanceInfoReplicator : There was a problem with the instance info replicator
java.lang.NoClassDefFoundError: jakarta/ws/rs/core/Response$Status
at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:828) ~[eureka-client-2.0.0.jar:2.0.0]
at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:121) ~[eureka-client-2.0.0.jar:2.0.0]
at com.netflix.discovery.InstanceInfoReplicator$1.run(InstanceInfoReplicator.java:101) ~[eureka-client-2.0.0.jar:2.0.0]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577) ~[na:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[na:na]
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:1589) ~[na:na]
Caused by: java.lang.ClassNotFoundException: jakarta.ws.rs.core.Response$Status
... 9 common frames omitted
2023-05-23T16:16:11.517+02:00 INFO 9872 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2023-05-23T16:16:11.528+02:00 INFO 9872 --- [ main] c.e.m.Microservice202203Application : Started Microservice202203Application in 9.125 seconds (process running for 9.716)
2023-05-23T16:16:11.610+02:00 INFO 9872 --- [-192.168.10.254] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-05-23T16:16:11.610+02:00 INFO 9872 --- [-192.168.10.254] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2023-05-23T16:16:11.611+02:00 INFO 9872 --- [-192.168.10.254] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
2023-05-23T16:16:14.900+02:00 ERROR 9872 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MICROSERVICE-2022-0-3/microservice-2022-0-3-01 - was unable to send heartbeat!
java.lang.NoClassDefFoundError: jakarta/ws/rs/core/Response$Status
at com.netflix.discovery.DiscoveryClient.renew(DiscoveryClient.java:839) ~[eureka-client-2.0.0.jar:2.0.0]
at com.netflix.discovery.DiscoveryClient$HeartbeatThread.run(DiscoveryClient.java:1401) ~[eureka-client-2.0.0.jar:2.0.0]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577) ~[na:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:1589) ~[na:na]
Caused by: java.lang.ClassNotFoundException: jakarta.ws.rs.core.Response$Status
... 7 common frames omitted
2023-05-23T16:16:19.906+02:00 ERROR 9872 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MICROSERVICE-2022-0-3/microservice-2022-0-3-01 - was unable to send heartbeat!
java.lang.NoClassDefFoundError: jakarta/ws/rs/core/Response$Status
at com.netflix.discovery.DiscoveryClient.renew(DiscoveryClient.java:839) ~[eureka-client-2.0.0.jar:2.0.0]
at com.netflix.discovery.DiscoveryClient$HeartbeatThread.run(DiscoveryClient.java:1401) ~[eureka-client-2.0.0.jar:2.0.0]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577) ~[na:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:1589) ~[na:na]
Caused by: java.lang.ClassNotFoundException: jakarta.ws.rs.core.Response$Status
... 7 common frames omitted
2023-05-23T16:16:24.918+02:00 ERROR 9872 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MICROSERVICE-2022-0-3/microservice-2022-0-3-01 - was unable to send heartbeat!
java.lang.NoClassDefFoundError: jakarta/ws/rs/core/Response$Status
at com.netflix.discovery.DiscoveryClient.renew(DiscoveryClient.java:839) ~[eureka-client-2.0.0.jar:2.0.0]
at com.netflix.discovery.DiscoveryClient$HeartbeatThread.run(DiscoveryClient.java:1401) ~[eureka-client-2.0.0.jar:2.0.0]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577) ~[na:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:1589) ~[na:na]
Caused by: java.lang.ClassNotFoundException: jakarta.ws.rs.core.Response$Status
... 7 common frames omitted
2023-05-23T16:16:29.934+02:00 ERROR 9872 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MICROSERVICE-2022-0-3/microservice-2022-0-3-01 - was unable to send heartbeat!
java.lang.NoClassDefFoundError: jakarta/ws/rs/core/Response$Status
at com.netflix.discovery.DiscoveryClient.renew(DiscoveryClient.java:839) ~[eureka-client-2.0.0.jar:2.0.0]
at com.netflix.discovery.DiscoveryClient$HeartbeatThread.run(DiscoveryClient.java:1401) ~[eureka-client-2.0.0.jar:2.0.0]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577) ~[na:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:1589) ~[na:na]
Caused by: java.lang.ClassNotFoundException: jakarta.ws.rs.core.Response$Status
... 7 common frames omitted
2023-05-23T16:16:34.947+02:00 ERROR 9872 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MICROSERVICE-2022-0-3/microservice-2022-0-3-01 - was unable to send heartbeat!
java.lang.NoClassDefFoundError: jakarta/ws/rs/core/Response$Status
at com.netflix.discovery.DiscoveryClient.renew(DiscoveryClient.java:839) ~[eureka-client-2.0.0.jar:2.0.0]
at com.netflix.discovery.DiscoveryClient$HeartbeatThread.run(DiscoveryClient.java:1401) ~[eureka-client-2.0.0.jar:2.0.0]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577) ~[na:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:1589) ~[na:na]
Caused by: java.lang.ClassNotFoundException: jakarta.ws.rs.core.Response$Status
... 7 common frames omitted
2023-05-23T16:16:39.881+02:00 INFO 9872 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2023-05-23T16:16:39.881+02:00 INFO 9872 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2023-05-23T16:16:39.881+02:00 INFO 9872 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2023-05-23T16:16:39.881+02:00 INFO 9872 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Application is null : false
2023-05-23T16:16:39.881+02:00 INFO 9872 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2023-05-23T16:16:39.881+02:00 INFO 9872 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2023-05-23T16:16:39.881+02:00 INFO 9872 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2023-05-23T16:16:39.893+02:00 INFO 9872 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MICROSERVICE-2022-0-3/microservice-2022-0-3-01 - was unable to refresh its cache! This periodic background refresh will be retried in 30 seconds. status = jakarta/ws/rs/core/Response$Status stacktrace = java.lang.NoClassDefFoundError: jakarta/ws/rs/core/Response$Status
at com.netflix.discovery.DiscoveryClient.getAndStoreFullRegistry(DiscoveryClient.java:1047)
at com.netflix.discovery.DiscoveryClient.fetchRegistry(DiscoveryClient.java:958)
at com.netflix.discovery.DiscoveryClient.refreshRegistry(DiscoveryClient.java:1475)
at com.netflix.discovery.DiscoveryClient$CacheRefreshThread.run(DiscoveryClient.java:1442)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1589)
Caused by: java.lang.ClassNotFoundException: jakarta.ws.rs.core.Response$Status
... 9 more
2023-05-23T16:16:39.928+02:00 INFO 9872 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MICROSERVICE-2022-0-3/microservice-2022-0-3-01: registering service...
2023-05-23T16:16:39.934+02:00 INFO 9872 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MICROSERVICE-2022-0-3/microservice-2022-0-3-01 - registration status: 204
2023-05-23T16:16:39.934+02:00 WARN 9872 --- [nfoReplicator-0] c.n.discovery.InstanceInfoReplicator : There was a problem with the instance info replicator
java.lang.NoClassDefFoundError: jakarta/ws/rs/core/Response$Status
at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:828) ~[eureka-client-2.0.0.jar:2.0.0]
at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:121) ~[eureka-client-2.0.0.jar:2.0.0]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577) ~[na:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[na:na]
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:1589) ~[na:na]
Caused by: java.lang.ClassNotFoundException: jakarta.ws.rs.core.Response$Status
... 8 common frames omitted
2023-05-23T16:16:39.963+02:00 ERROR 9872 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MICROSERVICE-2022-0-3/microservice-2022-0-3-01 - was unable to send heartbeat!
java.lang.NoClassDefFoundError: jakarta/ws/rs/core/Response$Status
at com.netflix.discovery.DiscoveryClient.renew(DiscoveryClient.java:839) ~[eureka-client-2.0.0.jar:2.0.0]
at com.netflix.discovery.DiscoveryClient$HeartbeatThread.run(DiscoveryClient.java:1401) ~[eureka-client-2.0.0.jar:2.0.0]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577) ~[na:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:1589) ~[na:na]
Caused by: java.lang.ClassNotFoundException: jakarta.ws.rs.core.Response$Status
... 7 common frames omitted
Comment From: ztomic
spring-cloud-starter-netflix-eureka-client-4.0.2-20230523.134656-112.jar is used
Comment From: spencergibb
Thank you so much for the report. I'll change the missing classes to check for the client implementation rather than the API which is still required. I'll also exclude the client impl rather than the api.
Comment From: ztomic
No problems! :) I have tested in provided sample and on product which I'm upgrading to SB 3.1.0 and now is all working OK. Thanks!
Comment From: mukulbindal
Is this issue fixed? I am still getting this issue in version 2022.0.2 with spring boot 3.0.6
Comment From: spencergibb
It's fixed in 2022.0.3
Comment From: HJK181
@spencergibb This fix broke our application after updating from 2022.0.2
to 2022.0.3
:
***************************
APPLICATION FAILED TO START
***************************
Description:
Field optionalArgs in org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration required a bean of type 'com.netflix.discovery.AbstractDiscoveryClientOptionalArgs' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'com.netflix.discovery.AbstractDiscoveryClientOptionalArgs' in your configuration.
Our application is a mix of spring-boot web application and our internal core that relies on Grizzly and therefore ships org.glassfish.jersey.client.JerseyClient
as a dependency. Besides the fact that this is a regression, I'm wondering what's the proper way to configure the eureka client if a JerseyClient is on the classpath?
As a workaround I created the following configuration class
@Profile("dev")
@Configuration
public class DiscoveryClientOptionalArgConfiguration {
@Bean
@ConditionalOnClass(name = { "org.springframework.web.client.RestTemplate", "org.glassfish.jersey.client.JerseyClient" })
@ConditionalOnMissingBean(value = { AbstractDiscoveryClientOptionalArgs.class }, search = SearchStrategy.CURRENT)
public RestTemplateDiscoveryClientOptionalArgs restTemplateDiscoveryClientOptionalArgs(EurekaClientHttpRequestFactorySupplier eurekaClientHttpRequestFactorySupplier) {
return new RestTemplateDiscoveryClientOptionalArgs(eurekaClientHttpRequestFactorySupplier);
}
@Bean
@ConditionalOnClass(name = { "org.springframework.web.client.RestTemplate", "org.glassfish.jersey.client.JerseyClient" })
@ConditionalOnMissingBean(value = { TransportClientFactories.class }, search = SearchStrategy.CURRENT)
public RestTemplateTransportClientFactories restTemplateTransportClientFactories(RestTemplateDiscoveryClientOptionalArgs optionalArgs) {
return new RestTemplateTransportClientFactories(optionalArgs);
}
}
Basically, I want the default behavior and need to duplicate the Spring code just with reversed conditions. Is there a better way to make this work and is there some documentation of it? I couldn't find one ... Thx.
Comment From: HJK181
@spencergibb any feedback is appreciated.
Comment From: CodeWeazle
Having the same now with 2022.0.4. All fine still with 2022.0.2
Comment From: CodingDochi
SpringCloudVersion 2023.0.0, SpringBoot 3.2, Java 17
I'm following this tutorial
@SpringBootApplication
public class ServiceRegistrationAndDiscoveryClientApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceRegistrationAndDiscoveryClientApplication.class, args);
}
}
@RestController
class ServiceInstanceRestController {
@Autowired
private DiscoveryClient discoveryClient;
@RequestMapping("/service-instances/{applicationName}")
public List<ServiceInstance> serviceInstancesByApplicationName(
@PathVariable String applicationName) {
return this.discoveryClient.getInstances(applicationName);
}
}
and got this error messages
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'scopedTarget.eurekaClient' defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class]: Unsatisfied dependency expressed through method 'eurekaClient' parameter 3: No qualifying bean of type 'com.netflix.discovery.shared.transport.jersey.TransportClientFactories<?>' available: expected at least 1 bean which qualifies as autowire candidate.
how can i fix this?
Comment From: spencergibb
@Dev-Hammy I am unable to reproduce using the guide and the complete version upgraded to the latest versions or boot and cloud.
If you'd like us to spend some time investigating, please take the time to provide a complete, minimal, verifiable sample (something that we can unzip attached to a new issue or git clone, build, and deploy) that reproduces the problem.
Comment From: CodingDochi
1. The complete version of the tutorial sample code
Thank you for responding to my inquiry. This is the complete code provided on the tutorial page.
gs-service-registration-and-discovery-main.zip
2. I got same structure and contents here :
In eureka-client
- ServiceRegistrationAndDiscoveryClientApplication.java
- resources/application.properties
In eureka-service
- ServiceRegistrationAndDiscoveryServiceApplication.java
- resources/application.properties
3. but different build.gradle
file.
build.gradle
for eureka-client
- the tutorial sample
build.gradle
foreureka-client
is :
plugins {
id 'org.springframework.boot' version '2.7.1'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '8'
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
}
ext {
set('springCloudVersion', "2021.0.3")
}
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
test {
useJUnitPlatform()
}
- and my
build.gradle
foreureka-client
is :
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.0'
id 'io.spring.dependency-management' version '1.1.4'
}
group = 'guides'
version = '0.0.1-SNAPSHOT'
java {
sourceCompatibility = '17'
}
repositories {
mavenCentral()
}
ext {
set('springCloudVersion', "2023.0.0")
}
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
tasks.named('test') {
useJUnitPlatform()
}
build.gradle
for eureka-service
- the tutorial sample
build.gradle
foreureka-service
is :
plugins {
id 'org.springframework.boot' version '2.7.1'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '8'
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
}
ext {
set('springCloudVersion', "2021.0.3")
}
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server'
testImplementation'org.springframework.boot:spring-boot-starter-test'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
test {
useJUnitPlatform()
}
- and my
build.gradle
foreureka-service
is :
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.0'
id 'io.spring.dependency-management' version '1.1.4'
}
group = 'guides'
version = '0.0.1-SNAPSHOT'
java {
sourceCompatibility = '17'
}
repositories {
mavenCentral()
}
ext {
set('springCloudVersion', "2023.0.0")
}
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
tasks.named('test') {
useJUnitPlatform()
}
4. running ServiceRegistrationAndDiscoveryServiceApplication
this issue may be related with current problem : BeanPostProcessor [lbRestClientPostProcessor] is declared through a non-static factory method on that class #1315
warning not eligible...
- left : my code having issue
- right : the tutorial sample code not having issue
mine does not implement Jersey
- right : the sample code has web application implementation (Jersey) and that implementation is being used by Eureka HTTP Client
- left : mine does not have any
running by process or JVM
- left : mine represents process running for 5.579
- right : the sample code printed out JVM running for 7.7072
5. running ServiceRegistrationAndDiscoveryClient
mine has two thread name
- left : mine has two thread name (
[a-bootiful-client] [main]
) - right : the sample code has one thread name (
[main]
)
similar warning message that has been printed out when running Service
- left : mine has warning message
- right : the sample code does not have warning message
mine does not use REST Template
- right : the sample code did DiscoveryClientOptionalArgsConfiguration
- left : nothing
error, error, closed
I Edited build.gradle
for eureka-client
and ServiceRegistrationAndDiscoveryServiceApplication
runs without Error but I'm not sure it is desired result. Why does my code uses two threads?
- before
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
- now
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
ServiceRegistrationAndDiscoveryServiceApplication
Still has warning messages Still does not implement Jersey Still running as process
ServiceRegistrationAndDiscoveryClientApplication
Still uses two thread [a-bootiful-client] [main]
Still has warning messages
DiscoveryClientOptionalArgsConfiguration : Eureka HTTPClient uses RestTemplate
Comment From: ZIRAKrezovic
Simple reproducer: Add spring-boot-starter-jeresey
Auto configuration report:
DiscoveryClientOptionalArgsConfiguration#defaultEurekaClientHttpRequestFactorySupplier matched:
- @ConditionalOnClass found required class 'org.springframework.web.client.RestTemplate' (OnClassCondition)
- @ConditionalOnMissingBean (types: org.springframework.cloud.netflix.eureka.http.EurekaClientHttpRequestFactorySupplier; SearchStrategy: all) did not find any beans (OnBeanCondition)
DiscoveryClientOptionalArgsConfiguration#restTemplateDiscoveryClientOptionalArgs:
Did not match:
- @ConditionalOnMissingClass found unwanted class 'org.glassfish.jersey.client.JerseyClient' (OnClassCondition)
DiscoveryClientOptionalArgsConfiguration#restTemplateTransportClientFactories:
Did not match:
- @ConditionalOnMissingClass found unwanted class 'org.glassfish.jersey.client.JerseyClient' (OnClassCondition)
DiscoveryClientOptionalArgsConfiguration.DiscoveryClientOptionalArgsTlsConfiguration:
Did not match:
- @ConditionalOnBean (types: com.netflix.discovery.AbstractDiscoveryClientOptionalArgs; SearchStrategy: current) did not find any beans of type com.netflix.discovery.AbstractDiscoveryClientOptionalArgs (OnBeanCondition)
Matched:
- @ConditionalOnClass found required class 'org.glassfish.jersey.client.JerseyClient' (OnClassCondition)
DiscoveryClientOptionalArgsConfiguration.WebClientConfiguration:
Did not match:
- @ConditionalOnClass did not find required class 'org.springframework.web.reactive.function.client.WebClient' (OnClassCondition)
DiscoveryClientOptionalArgsConfiguration.WebClientNotFoundConfiguration:
Did not match:
- @ConditionalOnMissingClass found unwanted class 'org.glassfish.jersey.client.JerseyClient' (OnClassCondition)
Eureka Server fixes this as follows (EurekaServerAutoConfiguration):
@Bean
@ConditionalOnMissingBean(AbstractDiscoveryClientOptionalArgs.class)
public Jersey3DiscoveryClientOptionalArgs jersey3DiscoveryClientOptionalArgs() {
return new Jersey3DiscoveryClientOptionalArgs();
}
Reproducer repo: https://github.com/ZIRAKrezovic/eureka-reproducer
./mvnw clean package spring-boot:run
Comment From: ZIRAKrezovic
Possible fix.
Mentioned Eureka Server fix comes from eureka-client-jeresey library. So, all the conditionals should be changed to check from org.glassfish.jersey.client.JerseyClient
to, for example,
com.netflix.discovery.shared.transport.jersey3.EurekaJersey3Client
Comment From: ZIRAKrezovic
Fix, v2:
Add
<dependency>
<groupId>com.netflix.eureka</groupId>
<artifactId>eureka-client-jersey3</artifactId>
</dependency>
Add:
import com.netflix.discovery.AbstractDiscoveryClientOptionalArgs;
import com.netflix.discovery.Jersey3DiscoveryClientOptionalArgs;
import com.netflix.discovery.shared.transport.jersey.TransportClientFactories;
import com.netflix.discovery.shared.transport.jersey3.Jersey3TransportClientFactories;
@Bean
@ConditionalOnMissingBean(AbstractDiscoveryClientOptionalArgs.class)
public Jersey3DiscoveryClientOptionalArgs jersey3DiscoveryClientOptionalArgs() {
return new Jersey3DiscoveryClientOptionalArgs();
}
@Bean
@ConditionalOnMissingBean(TransportClientFactories.class)
public Jersey3TransportClientFactories jersey3TransportClientFactories() {
return Jersey3TransportClientFactories.getInstance();
}
Change existing conditionals from org.glassfish.jersey.client.JerseyClient
to com.netflix.discovery.shared.transport.jersey3.EurekaJersey3Client