spring-cloud / spring-cloud-consul

Spring Cloud Consul
http://cloud.spring.io/spring-cloud-consul/
Apache License 2.0
813 stars 541 forks source link

Spring native application startup NPE exception after turned on consul integration #805

Closed nikita-efremov1 closed 1 year ago

nikita-efremov1 commented 1 year ago

Describe the bug We have a spring6 application that compiled into graalvm native image and run in a docker environment. After we turned on consul integration application couldn't start due to error. Application is started successfully while using "java -jar application.jar" and "java -Dspring.aot.enabled=true -jar application.jar".

System Info:

Stack trace

org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[spring6-poc-service:6.0.2]
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[na:na]
    at java.base@17.0.5/java.lang.Iterable.forEach(Iterable.java:75) ~[spring6-poc-service:na]
    at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) ~[spring6-poc-service:6.0.2]
    at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[spring6-poc-service:6.0.2]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:932) ~[spring6-poc-service:6.0.2]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:587) ~[spring6-poc-service:6.0.2]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring6-poc-service:3.0.0]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring6-poc-service:3.0.0]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[spring6-poc-service:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring6-poc-service:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[spring6-poc-service:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[spring6-poc-service:3.0.0]
    at wkda.api.Application.main(Application.java:16) ~[spring6-poc-service:na]
Caused by: java.lang.NullPointerException: null
    at org.springframework.aop.framework.AdvisedSupport$MethodCacheKey.<init>(AdvisedSupport.java:578) ~[spring6-poc-service:6.0.2]
    at org.springframework.aop.framework.AdvisedSupport.getInterceptorsAndDynamicInterceptionAdvice(AdvisedSupport.java:470) ~[spring6-poc-service:6.0.2]
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689) ~[na:na]
    at org.springframework.cloud.consul.serviceregistry.ConsulAutoServiceRegistration$$SpringCGLIB$$0.setPortIfNeeded(<generated>) ~[spring6-poc-service:na]
    at org.springframework.cloud.consul.serviceregistry.ConsulAutoServiceRegistrationListener.onApplicationEvent(ConsulAutoServiceRegistrationListener.java:59) ~[spring6-poc-service:na]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[na:na]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[na:na]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[na:na]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:413) ~[spring6-poc-service:6.0.2]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:370) ~[spring6-poc-service:6.0.2]
    at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:47) ~[na:na]
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[spring6-poc-service:6.0.2]   ... 13 common frames omitted

Full application logs

10:17:22.461 [main] INFO wkda.api.Application - start from logger

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.0.0)

2023-01-10T10:17:22.517Z  INFO [spring6-poc-service,,] 7 --- [           main] wkda.api.Application                     : Starting AOT-processed Application using Java 17.0.5 with PID 7 (/srv/app/spring6-poc-service started by root in /srv/app)
2023-01-10T10:17:22.517Z  INFO [spring6-poc-service,,] 7 --- [           main] wkda.api.Application                     : No active profile set, falling back to 1 default profile: "default"
2023-01-10T10:17:22.531Z  WARN [spring6-poc-service,,] 7 --- [           main] o.s.c.annotation.AnnotationTypeMapping   : Support for convention-based annotation attribute overrides is deprecated and will be removed in Spring Framework 6.1. Please annotate the following attributes in @org.springframework.retry.annotation.EnableRetry with appropriate @AliasFor declarations: [proxyTargetClass]
2023-01-10T10:17:22.551Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.tomcat.util.compat.Jre19Compat  : Class not found so assuming code is running on a pre-Java 19 JVM

java.lang.ClassNotFoundException: java.lang.WrongThreadException. This exception was synthesized during native image building from a call to java.lang.Class.forName(String) with constant arguments.
    at org.apache.tomcat.util.compat.Jre19Compat.<clinit>(Jre19Compat.java:37) ~[na:na]
    at org.apache.tomcat.util.compat.JreCompat.<clinit>(JreCompat.java:53) ~[spring6-poc-service:10.1.1]
    at org.apache.catalina.startup.Tomcat.<clinit>(Tomcat.java:1281) ~[na:na]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:193) ~[spring6-poc-service:3.0.0]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:183) ~[spring6-poc-service:3.0.0]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161) ~[spring6-poc-service:3.0.0]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:578) ~[spring6-poc-service:6.0.2]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring6-poc-service:3.0.0]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring6-poc-service:3.0.0]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[spring6-poc-service:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring6-poc-service:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[spring6-poc-service:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[spring6-poc-service:3.0.0]
    at wkda.api.Application.main(Application.java:16) ~[spring6-poc-service:na]

2023-01-10T10:17:22.554Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.tomcat.util.IntrospectionUtils  : IntrospectionUtils: setProperty(class org.apache.coyote.http11.Http11NioProtocol port=1000)
2023-01-10T10:17:22.555Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.tomcat.util.IntrospectionUtils  : IntrospectionUtils: setProperty(class org.apache.coyote.http11.Http11NioProtocol bindOnInit=false)
2023-01-10T10:17:22.556Z DEBUG [spring6-poc-service,,] 7 --- [           main] org.apache.catalina.core.ContainerBase   : Add child StandardHost[localhost] StandardEngine[Tomcat]
2023-01-10T10:17:22.556Z DEBUG [spring6-poc-service,,] 7 --- [           main] org.apache.catalina.core.ContainerBase   : Add child TomcatEmbeddedContext[] StandardEngine[Tomcat].StandardHost[localhost]
2023-01-10T10:17:22.557Z  INFO [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-01-10T10:17:22.557Z  INFO [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.1]
2023-01-10T10:17:22.557Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.core.StandardContext   : Starting ROOT
2023-01-10T10:17:22.558Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.core.StandardContext   : Configuring default Resources
2023-01-10T10:17:22.560Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.core.StandardContext   : Processing standard container startup
2023-01-10T10:17:22.561Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.loader.WebappLoader    : Starting this Loader
2023-01-10T10:17:22.562Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.authenticator.AuthenticatorBase    : No SingleSignOn Valve is present
2023-01-10T10:17:22.562Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.core.StandardContext   : No manager found. Checking if cluster manager should be used. Cluster configured: [false], Application distributable: [false]
2023-01-10T10:17:22.562Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.core.StandardContext   : Configured a manager of class [org.apache.catalina.session.StandardManager]
2023-01-10T10:17:22.562Z  INFO [spring6-poc-service,,] 7 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-01-10T10:17:22.579Z DEBUG [spring6-poc-service,,] 7 --- [           main] i.m.c.u.i.logging.InternalLoggerFactory  : Using SLF4J as the default logging framework
2023-01-10T10:17:22.601Z DEBUG [spring6-poc-service,,] 7 --- [           main] org.apache.catalina.core.ContainerBase   : Add child StandardWrapper[dispatcherServlet] StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]
2023-01-10T10:17:22.601Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.core.StandardContext   : Configuring application event listeners
2023-01-10T10:17:22.602Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Sending application start events
2023-01-10T10:17:22.602Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.catalina.session.StandardManager     : Start: Loading persisted sessions
2023-01-10T10:17:22.602Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Starting filters
2023-01-10T10:17:22.602Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Starting filter 'requestContextFilter'
2023-01-10T10:17:22.602Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Starting filter 'tracingHeadersFilter'
2023-01-10T10:17:22.602Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Starting filter 'Tomcat WebSocket (JSR356) Filter'
2023-01-10T10:17:22.602Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Starting filter 'serverHttpObservationFilter'
2023-01-10T10:17:22.602Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Starting filter 'characterEncodingFilter'
2023-01-10T10:17:22.602Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Starting filter 'formContentFilter'
2023-01-10T10:17:22.602Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.core.StandardContext   : Starting completed
2023-01-10T10:17:22.602Z DEBUG [spring6-poc-service,,] 7 --- [           main] org.apache.catalina.mapper.Mapper        : Registered host [localhost]
2023-01-10T10:17:22.602Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.mapper.MapperListener  : Register Wrapper [dispatcherServlet] in Context [] for service [StandardService[Tomcat]]
2023-01-10T10:17:22.602Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.mapper.MapperListener  : Register Context [] for service [StandardService[Tomcat]]
2023-01-10T10:17:22.603Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.mapper.MapperListener  : Register host [localhost] at domain [null] for service [StandardService[Tomcat]]
2023-01-10T10:17:22.666Z DEBUG [spring6-poc-service,,] 7 --- [           main] org.jboss.logging                        : Logging Provider: org.jboss.logging.Slf4jLoggerProvider found via system property
2023-01-10T10:17:22.736Z DEBUG [spring6-poc-service,,] 7 --- [           main] _.s.web.servlet.HandlerMapping.Mappings  : 
    w.a.c.EmployeeVerificationController:
    {PUT [/v1/status/{id} || /status/{id}]}: updateState(Employee,UUID)
    {GET [/v1/test/circuit-breaker/{id} || /test/circuit-breaker/{id}]}: testCircuitBreaker(UUID)
    {GET [/v1/test/retry/{id} || /test/retry/{id}]}: testRetry(UUID)
    {GET [/v1/test/timeout/{id} || /test/timeout/{id}]}: checkTimeout(UUID)
    {DELETE [/v1/test/bulkhead/{id} || /test/bulkhead/{id}]}: testBulkhead(UUID)
    {DELETE [/v1/test/ratelimiter/{id} || /test/ratelimiter/{id}]}: testRateLimiter(UUID)
    {POST [/v1/verify || /verify]}: verify(Employee)
2023-01-10T10:17:22.737Z DEBUG [spring6-poc-service,,] 7 --- [           main] _.s.web.servlet.HandlerMapping.Mappings  : 
    o.s.b.a.w.s.e.BasicErrorController:
    { [/error]}: error(HttpServletRequest)
    { [/error], produces [text/html]}: errorHtml(HttpServletRequest,HttpServletResponse)
2023-01-10T10:17:22.739Z DEBUG [spring6-poc-service,,] 7 --- [           main] _.s.web.servlet.HandlerMapping.Mappings  : 'beanNameHandlerMapping' {}
2023-01-10T10:17:22.739Z DEBUG [spring6-poc-service,,] 7 --- [           main] _.s.web.servlet.HandlerMapping.Mappings  : 'resourceHandlerMapping' {/webjars/**=ResourceHttpRequestHandler [classpath [META-INF/resources/webjars/]], /**=ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]}
2023-01-10T10:17:22.787Z  WARN [spring6-poc-service,,] 7 --- [           main] i.m.c.i.binder.jvm.JvmGcMetrics          : GC notifications will not be available because MemoryPoolMXBeans are not provided by the JVM
2023-01-10T10:17:22.802Z  WARN [spring6-poc-service,,] 7 --- [           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-01-10T10:17:22.813Z DEBUG [spring6-poc-service,,] 7 --- [o-1000-Acceptor] o.apache.tomcat.util.threads.LimitLatch  : Counting up[http-nio-1000-Acceptor] latch=0
2023-01-10T10:17:22.825Z  WARN [spring6-poc-service,,] 7 --- [           main] w.s.c.ServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'
2023-01-10T10:17:22.830Z DEBUG [spring6-poc-service,,] 7 --- [           main] org.apache.tomcat.util.net.NioEndpoint   : About to unlock socket for:/172.17.0.3:1000
2023-01-10T10:17:22.830Z DEBUG [spring6-poc-service,,] 7 --- [           main] org.apache.tomcat.util.net.NioEndpoint   : Socket unlock completed for:/172.17.0.3:1000
2023-01-10T10:17:22.830Z  INFO [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2023-01-10T10:17:22.830Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.mapper.MapperListener  : Unregister host [localhost] at domain [null] for service [StandardService[Tomcat]]
2023-01-10T10:17:22.831Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.mapper.MapperListener  : Unregister Context [] for service [StandardService[Tomcat]]
2023-01-10T10:17:22.831Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.mapper.MapperListener  : Unregister Wrapper [dispatcherServlet] in Context [] for service [StandardService[Tomcat]]
2023-01-10T10:17:22.831Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Stopping filters
2023-01-10T10:17:22.831Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Stopping filter 'requestContextFilter'
2023-01-10T10:17:22.831Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.core.ApplicationFilterConfig       : JMX de-registration complete for filter of type [org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter] and name [requestContextFilter]
2023-01-10T10:17:22.831Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Stopping filter 'tracingHeadersFilter'
2023-01-10T10:17:22.831Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.core.ApplicationFilterConfig       : JMX de-registration complete for filter of type [wkda.api.tracing.TracingHeadersFilter] and name [tracingHeadersFilter]
2023-01-10T10:17:22.831Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Stopping filter 'Tomcat WebSocket (JSR356) Filter'
2023-01-10T10:17:22.831Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.core.ApplicationFilterConfig       : JMX de-registration complete for filter of type [org.apache.tomcat.websocket.server.WsFilter] and name [Tomcat WebSocket (JSR356) Filter]
2023-01-10T10:17:22.831Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Stopping filter 'serverHttpObservationFilter'
2023-01-10T10:17:22.831Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.core.ApplicationFilterConfig       : JMX de-registration complete for filter of type [org.springframework.web.filter.ServerHttpObservationFilter] and name [serverHttpObservationFilter]
2023-01-10T10:17:22.831Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Stopping filter 'characterEncodingFilter'
2023-01-10T10:17:22.831Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.core.ApplicationFilterConfig       : JMX de-registration complete for filter of type [org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter] and name [characterEncodingFilter]
2023-01-10T10:17:22.831Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Stopping filter 'formContentFilter'
2023-01-10T10:17:22.831Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.c.core.ApplicationFilterConfig       : JMX de-registration complete for filter of type [org.springframework.boot.web.servlet.filter.OrderedFormContentFilter] and name [formContentFilter]
2023-01-10T10:17:22.831Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.catalina.session.StandardManager     : Stopping
2023-01-10T10:17:22.831Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.catalina.session.StandardManager     : Unloading persisted sessions
2023-01-10T10:17:22.832Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.a.catalina.session.StandardManager     : No persisted sessions to unload
2023-01-10T10:17:22.832Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.core.StandardContext   : Sending application stop events
2023-01-10T10:17:22.832Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.core.StandardContext   : Processing standard container shutdown
2023-01-10T10:17:22.832Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.loader.WebappLoader    : Stopping this Loader
2023-01-10T10:17:22.832Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.core.StandardContext   : resetContext Tomcat:j2eeType=WebModule,name=//localhost/,J2EEApplication=none,J2EEServer=none
2023-01-10T10:17:22.832Z DEBUG [spring6-poc-service,,] 7 --- [           main] o.apache.catalina.core.StandardContext   : Stopping complete
2023-01-10T10:17:22.834Z DEBUG [spring6-poc-service,,] 7 --- [           main] org.apache.tomcat.util.net.NioEndpoint   : Destroy initiated for 0.0.0.0/0.0.0.0:1000
2023-01-10T10:17:22.834Z DEBUG [spring6-poc-service,,] 7 --- [           main] org.apache.tomcat.util.net.NioEndpoint   : Destroy completed for 0.0.0.0/0.0.0.0:1000
2023-01-10T10:17:22.835Z ERROR [spring6-poc-service,,] 7 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[spring6-poc-service:6.0.2]
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[na:na]
    at java.base@17.0.5/java.lang.Iterable.forEach(Iterable.java:75) ~[spring6-poc-service:na]
    at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) ~[spring6-poc-service:6.0.2]
    at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[spring6-poc-service:6.0.2]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:932) ~[spring6-poc-service:6.0.2]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:587) ~[spring6-poc-service:6.0.2]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring6-poc-service:3.0.0]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring6-poc-service:3.0.0]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[spring6-poc-service:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring6-poc-service:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[spring6-poc-service:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[spring6-poc-service:3.0.0]
    at wkda.api.Application.main(Application.java:16) ~[spring6-poc-service:na]
Caused by: java.lang.NullPointerException: null
    at org.springframework.aop.framework.AdvisedSupport$MethodCacheKey.<init>(AdvisedSupport.java:578) ~[spring6-poc-service:6.0.2]
    at org.springframework.aop.framework.AdvisedSupport.getInterceptorsAndDynamicInterceptionAdvice(AdvisedSupport.java:470) ~[spring6-poc-service:6.0.2]
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689) ~[na:na]
    at org.springframework.cloud.consul.serviceregistry.ConsulAutoServiceRegistration$$SpringCGLIB$$0.setPortIfNeeded(<generated>) ~[spring6-poc-service:4.0.0]
    at org.springframework.cloud.consul.serviceregistry.ConsulAutoServiceRegistrationListener.onApplicationEvent(ConsulAutoServiceRegistrationListener.java:59) ~[spring6-poc-service:4.0.0]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[na:na]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[na:na]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[na:na]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:413) ~[spring6-poc-service:6.0.2]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:370) ~[spring6-poc-service:6.0.2]
    at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:47) ~[na:na]
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[spring6-poc-service:6.0.2]
    ... 13 common frames omitted
nikita-efremov1 commented 1 year ago

We don't need the "service auto registration" functionality, so we turned it off by setting up the parameter "spring.cloud.service-registry.auto-registration.enabled=false". After that consul integration became work without errors.

d-eder commented 1 year ago

But this still seems to be an issue and should be fixed/investigated. Could you please reopen the issue? The same issue is also posted on the spring-boot repo: https://github.com/spring-projects/spring-boot/issues/33248

OlgaMaciaszek commented 1 year ago

Hello, @nikita-efremov1, thanks for reporting the issue. We do have a basic sample test with Spring Cloud Consul that is not reporting any issues, so if you're still facing the issue with the newest Spring Boot and Spring Cloud version, please provide a minimal, complete, verifiable example that reproduces the issue.

@d-eder that was a different issue altogether (adding AOT and native support for SC OF in the first place) and has been implemented before the GA release.

spring-cloud-issues commented 1 year 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.

nikita-efremov1 commented 1 year ago

Hello, @OlgaMaciaszek. Thanks for answering!

I have added the test project which reporting the issue. The problem appeared after adding dependencies "spring-retry" and "spring-cloud-starter-openfeign". Before adding these dependencies the proxy class file (look at the stacktrace above) is not generated and we don't see the error. After reproducing the problem and publishing the github project I checked that using "spring-boot-starter-parent:3.0.4" version helped solving the problem. It seems to me that we can close the issue.

OlgaMaciaszek commented 1 year ago

Thanks, @nikita-efremov1. Closing as already fixed.