apache / dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
https://dubbo.apache.org/
Apache License 2.0
40.44k stars 26.42k forks source link

在Dubbo的基础上增加Seata启动报DubboBootstrap is not initialized #8304

Closed caozhigang515 closed 3 years ago

caozhigang515 commented 3 years ago

Environment

Steps to reproduce this issue

加入seata后 consumer端 启动报错如下:

 DubboBootStrap is not initialized

引入依赖为

...
<dependency>
    <groupId>org.apache.dubbo</groupId>
    <artifactId>dubbo-spring-boot-starter</artifactId>
    <version>3.0.1</version>
</dependency>

<dependency>
    <groupId>org.apache.dubbo</groupId>
    <artifactId>dubbo-registry-nacos</artifactId>
    <version>3.0.1</version>
    <exclusions>
        <exclusion>
            <artifactId>commons-logging</artifactId>
            <groupId>commons-logging</groupId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-seata</artifactId>
    <version>2021.1</version>
    <exclusions>
        <exclusion>
            <groupId>io.seata</groupId>
            <artifactId>seata-all</artifactId>
        </exclusion>
        <exclusion>
            <groupId>io.seata</groupId>
            <artifactId>seata-spring-boot-starter</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>io.seata</groupId>
    <artifactId>seata-all</artifactId>
    <version>1.4.2</version>
</dependency>

<dependency>
    <groupId>io.seata</groupId>
    <artifactId>seata-spring-boot-starter</artifactId>
    <version>1.4.2</version>
</dependency>
...

Pls. provide [GitHub address] to reproduce this issue.

Expected Result

What do you expected from the above steps?

Actual Result

What actually happens?

If there is an exception, please attach the exception trace:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-07-16 15:36:27.549 ERROR 13510 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'demoController' defined in file [/Users/caozhigang/WorkSpace/DFLZ/src/com.dflz.trip/1-trip/trip-car-rental/trip-car-rental-service/target/classes/com/dflz/trip/carrental/service/service/controller/DemoController.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'demoService': Post-processing of FactoryBean's singleton object failed; nested exception is java.lang.RuntimeException: java.lang.IllegalStateException: DubboBootstrap is not initialized
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:610) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.8.jar:5.3.8]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.8.jar:5.3.8]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.2.jar:2.5.2]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) [spring-boot-2.5.2.jar:2.5.2]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) [spring-boot-2.5.2.jar:2.5.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) [spring-boot-2.5.2.jar:2.5.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) [spring-boot-2.5.2.jar:2.5.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) [spring-boot-2.5.2.jar:2.5.2]
    at com.xxx.xxx.carrental.service.AppRun.main(AppRun.java:15) [classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'demoService': Post-processing of FactoryBean's singleton object failed; nested exception is java.lang.RuntimeException: java.lang.IllegalStateException: DubboBootstrap is not initialized
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:119) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1884) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getObjectForBeanInstance(AbstractAutowireCapableBeanFactory.java:1266) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:345) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.doGetInjectedBean(ReferenceAnnotationBeanPostProcessor.java:475) ~[dubbo-3.0.1.jar:3.0.1]
    at org.apache.dubbo.config.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.getInjectedObject(AbstractAnnotationBeanPostProcessor.java:356) ~[dubbo-3.0.1.jar:3.0.1]
    at org.apache.dubbo.config.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor$AnnotatedInjectElement.inject(AbstractAnnotationBeanPostProcessor.java:465) ~[dubbo-3.0.1.jar:3.0.1]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.postProcessPropertyValues(ReferenceAnnotationBeanPostProcessor.java:294) ~[dubbo-3.0.1.jar:3.0.1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1418) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601) ~[spring-beans-5.3.8.jar:5.3.8]
    ... 15 common frames omitted
Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: DubboBootstrap is not initialized
    at io.seata.spring.annotation.GlobalTransactionScanner.wrapIfNecessary(GlobalTransactionScanner.java:287) ~[seata-all-1.4.2.jar:1.4.2]
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:290) ~[spring-aop-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:437) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.postProcessObjectFromFactoryBean(AbstractAutowireCapableBeanFactory.java:1929) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:116) ~[spring-beans-5.3.8.jar:5.3.8]
    ... 26 common frames omitted
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) ~[na:1.8.0_281]
    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.3.8.jar:5.3.8]
    at io.seata.spring.util.SpringProxyUtils.findTargetClass(SpringProxyUtils.java:51) ~[seata-all-1.4.2.jar:1.4.2]
    at io.seata.spring.annotation.GlobalTransactionScanner.wrapIfNecessary(GlobalTransactionScanner.java:256) ~[seata-all-1.4.2.jar:1.4.2]
    ... 30 common frames omitted
kylixs commented 3 years ago

@caozhigang515 dubbo 3.0.1 + seata 1.4.2 can reproduce this problem. dubbo 3.0.2 improves the initialization process and can support seata 1.4.2. But 3.0.2 has not been released yet, please build it locally based on the 3.0 branch, and then test it.

CrazyHZM commented 3 years ago

The above answer should solve your problem, temporarily close the issue, if there are other problems, you can open the issue at any time @caozhigang515