Dubbo 3.0.1 with SpringBoot 2.3.3 @PostConstruct init method call dubbo service, project start failed, Throw java.lang.IllegalStateException: DubboBootstrap is not initialized
Environment
- Dubbo version: 3.0.1
- Operating System version: maxOS Catalina 10.15.7
- Java version: 1.8.0_171-b11
Steps to reproduce this issue
- in consumer project, use @PostConstruct with init method
- init method call dubbo service will start failed
reproduce this issue github address:
https://github.com/leimbag/test-spring-dubbo
Expected Result
Springboot use @PostConstruct ,in init method call dubbo service will start success, when I use dubbo 2.7.8 or dubbo 2.7.12 will start success, but 3.0.1 will start failed
Actual Result
Spring Boot start failed, if I use @PostConstruct with init method call dubbo service to do something, the consumer project start failed.
the exception trace:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.3.RELEASE)
2021-08-02 12:16:34,675 [INFO] [mainraceId] (main) o.s.c.b.c.PropertySourceBootstrapConfiguration.initialize:105 - Located property source: [BootstrapPropertySource {name='bootstrapProperties-example-dubbo-consumer-dev.properties,example-dubbo-consumer'}, BootstrapPropertySource {name='bootstrapProperties-example-dubbo-consumer.properties,example-dubbo-consumer'}, BootstrapPropertySource {name='bootstrapProperties-example-dubbo-consumer,example-dubbo-consumer'}]
2021-08-02 12:16:34,683 [INFO] [mainraceId] (main) c.e.d.d.SpringDubboConsumerApplication.logStartupProfileInfo:655 - The following profiles are active: dev
2021-08-02 12:16:35,807 [INFO] [mainraceId] (main) o.a.d.c.c.ConfigManager.<clinit>:98 - [DUBBO] Unique config types: [MonitorConfig, ApplicationConfig, ModuleConfig, SslConfig, MetricsConfig], dubbo version: 3.0.1, current host: 192.168.201.95
2021-08-02 12:16:35,868 [INFO] [mainraceId] (main) o.s.c.c.s.GenericScope.setSerializationId:295 - BeanFactory id=3fe3c2cc-f0e8-3cd4-8f4d-619f806f8458
2021-08-02 12:16:35,873 [INFO] [mainraceId] (main) o.a.d.c.c.ConfigManager.initialize:112 - [DUBBO] Dubbo config mode: STRICT, dubbo version: 3.0.1, current host: 192.168.201.95
2021-08-02 12:16:36,060 [WARN] [mainraceId] (main) o.s.b.c.p.PropertySourcesDeducer.getSinglePropertySourcesPlaceholderConfigurer:66 - Multiple PropertySourcesPlaceholderConfigurer beans registered [propertySourcesPlaceholderConfigurer, org.springframework.context.support.PropertySourcesPlaceholderConfigurer], falling back to Environment
2021-08-02 12:16:36,079 [INFO] [mainraceId] (main) o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker.postProcessAfterInitialization:335 - Bean 'example-dubbo-consumer' of type [org.apache.dubbo.config.ApplicationConfig] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-08-02 12:16:36,289 [INFO] [mainraceId] (main) o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker.postProcessAfterInitialization:335 - Bean 'org.apache.dubbo.config.RegistryConfig#0' of type [org.apache.dubbo.config.RegistryConfig] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-08-02 12:16:36,305 [INFO] [mainraceId] (main) o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker.postProcessAfterInitialization:335 - Bean 'dubbo' of type [org.apache.dubbo.config.ProtocolConfig] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-08-02 12:16:36,312 [INFO] [mainraceId] (main) o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker.postProcessAfterInitialization:335 - Bean 'org.apache.dubbo.config.MonitorConfig#0' of type [org.apache.dubbo.config.MonitorConfig] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-08-02 12:16:36,330 [INFO] [mainraceId] (main) o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker.postProcessAfterInitialization:335 - Bean 'org.apache.dubbo.config.ConsumerConfig#0' of type [org.apache.dubbo.config.ConsumerConfig] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-08-02 12:16:36,673 [INFO] [mainraceId] (main) o.s.b.w.e.t.TomcatWebServer.initialize:108 - Tomcat initialized with port(s): 9802 (http)
2021-08-02 12:16:36,816 [INFO] [mainraceId] (main) o.s.b.w.s.c.ServletWebServerApplicationContext.prepareWebApplicationContext:285 - Root WebApplicationContext: initialization completed in 2116 ms
2021-08-02 12:16:37,102 [INFO] [mainraceId] (main) o.a.d.c.s.r.ReferenceCreator.build:95 - The configBean[type:ReferenceConfig] has been built.
2021-08-02 12:16:37,127 [WARN] [mainraceId] (main) o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext.refresh:559 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testController': Invocation of init method failed; nested exception is java.lang.IllegalStateException: DubboBootstrap is not initialized
2021-08-02 12:16:37,127 [INFO] [mainraceId] (main) o.a.d.c.s.b.f.a.ReferenceAnnotationBeanPostProcessor.destroy:304 - class org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor was destroying!
2021-08-02 12:16:37,139 [INFO] [mainraceId] (main) o.s.b.a.l.ConditionEvaluationReportLoggingListener.logMessage:136 -
八月 02, 2021 12:16:37 下午 org.apache.catalina.core.StandardService stopInternal
信息: Stopping service [Tomcat]
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-08-02 12:16:37,148 [ERROR] [mainraceId] (main) o.s.b.SpringApplication.reportFailure:837 - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testController': Invocation of init method failed; nested exception is java.lang.IllegalStateException: DubboBootstrap is not initialized
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:415) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1786) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at com.example.dubbo.demo.SpringDubboConsumerApplication.main(SpringDubboConsumerApplication.java:15) [classes/:?]
Caused by: java.lang.IllegalStateException: DubboBootstrap is not initialized
at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:244) ~[dubbo-3.0.1.jar:3.0.1]
at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:205) ~[dubbo-3.0.1.jar:3.0.1]
at org.apache.dubbo.config.utils.ReferenceConfigCache.lambda$get$3(ReferenceConfigCache.java:114) ~[dubbo-3.0.1.jar:3.0.1]
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) ~[?:1.8.0_171]
at org.apache.dubbo.config.utils.ReferenceConfigCache.get(ReferenceConfigCache.java:113) ~[dubbo-3.0.1.jar:3.0.1]
at org.apache.dubbo.config.spring.ReferenceBean.getCallProxy(ReferenceBean.java:344) ~[dubbo-3.0.1.jar:3.0.1]
at org.apache.dubbo.config.spring.ReferenceBean.access$100(ReferenceBean.java:97) ~[dubbo-3.0.1.jar:3.0.1]
at org.apache.dubbo.config.spring.ReferenceBean$DubboReferenceLazyInitTargetSource.createObject(ReferenceBean.java:351) ~[dubbo-3.0.1.jar:3.0.1]
at org.springframework.aop.target.AbstractLazyCreationTargetSource.getTarget(AbstractLazyCreationTargetSource.java:88) ~[spring-aop-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192) ~[spring-aop-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at com.sun.proxy.$Proxy82.hello(Unknown Source) ~[?:?]
at com.example.dubbo.demo.controller.TestController.init(TestController.java:30) ~[classes/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_171]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_171]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_171]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_171]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
... 19 more
2021-08-02 12:16:37,153 [INFO] [DubboShutdownHookraceId] (DubboShutdownHook) o.a.d.c.DubboShutdownHook.run:61 - [DUBBO] Run shutdown hook now., dubbo version: 3.0.1, current host: 192.168.201.95
2021-08-02 12:16:37,156 [INFO] [DubboShutdownHookraceId] (DubboShutdownHook) o.a.d.r.s.AbstractRegistryFactory.destroyAll:94 - [DUBBO] Close all registries [], dubbo version: 3.0.1, current host: 192.168.201.95
Already resolved in #8168 and will released in version 3.0.2
By now ,you can use ApplicationRunner or CommandLineRunner instead of @PostConstruct to make your program runnable again
By now ,you can use ApplicationRunner or CommandLineRunner instead of @PostConstruct to make your program runnable again
Thanks, too many need to chanage.