apache / dubbo

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

java.lang.RuntimeException: java.lang.IllegalStateException: Extension instance (name: spring, class: interface org.apache.dubbo.rpc.protocol.tri.rest.mapping.RequestMappingResolver) couldn't be instantiated: null #14740

Closed lbh6771740 closed 1 month ago

lbh6771740 commented 2 months ago

Pre-check

Search before asking

Apache Dubbo Component

Java SDK (apache/dubbo)

Dubbo Version

spring-boot 2.7.14 spring-cloud 2021.0.8 spring-cloud-alibaba 2021.0.4.0 Dubbo 3.3.0 JDK 1.8

Steps to reproduce this issue

When I use dubbo-bom 3.2.16 in the project, everything starts up normally and external services can be provided without any issues. However, when I try to upgrade to dubbo-bom 3.3.0, starting the Spring Boot application results in an error related to multiple ConversionService Beans. I am currently unable to solve this issue, so I need help on how to upgrade to dubbo-bom 3.3.0 and ensure that the application starts up successfully. Thank you.

java.lang.RuntimeException: java.lang.IllegalStateException: Extension instance (name: spring, class: interface org.apache.dubbo.rpc.protocol.tri.rest.mapping.RequestMappingResolver) couldn't be instantiated: null
    at org.apache.dubbo.registry.integration.ExporterFactory.lambda$createExporter$0(ExporterFactory.java:33)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
    at org.apache.dubbo.registry.integration.ExporterFactory.createExporter(ExporterFactory.java:29)
    at org.apache.dubbo.registry.integration.RegistryProtocol.doLocalExport(RegistryProtocol.java:354)
    at org.apache.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:289)
    at org.apache.dubbo.rpc.protocol.ProtocolSecurityWrapper.export(ProtocolSecurityWrapper.java:84)
    at org.apache.dubbo.qos.protocol.QosProtocolWrapper.export(QosProtocolWrapper.java:79)
    at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:66)
    at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:58)
    at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.export(ProtocolSerializationWrapper.java:50)
    at org.apache.dubbo.rpc.protocol.InvokerCountWrapper.export(InvokerCountWrapper.java:42)
    at org.apache.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java)
    at org.apache.dubbo.config.ServiceConfig.doExportUrl(ServiceConfig.java:969)
    at org.apache.dubbo.config.ServiceConfig.exportRemote(ServiceConfig.java:939)
    at org.apache.dubbo.config.ServiceConfig.exportUrl(ServiceConfig.java:876)
    at org.apache.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:622)
    at org.apache.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:600)
    at org.apache.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:555)
    at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:343)
    at org.apache.dubbo.config.deploy.DefaultModuleDeployer.exportServiceInternal(DefaultModuleDeployer.java:495)
    at org.apache.dubbo.config.deploy.DefaultModuleDeployer.exportServices(DefaultModuleDeployer.java:442)
    at org.apache.dubbo.config.deploy.DefaultModuleDeployer.startSync(DefaultModuleDeployer.java:177)
    at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:159)
    at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onContextRefreshedEvent(DubboDeployApplicationListener.java:167)
    at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:153)
    at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:52)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378)
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:941)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)
    at com.ssm.app.application.SsmApplication.main(SsmApplication.java:32)
Caused by: java.lang.IllegalStateException: Extension instance (name: spring, class: interface org.apache.dubbo.rpc.protocol.tri.rest.mapping.RequestMappingResolver) couldn't be instantiated: null
    at org.apache.dubbo.common.extension.ExtensionLoader.createExtension(ExtensionLoader.java:818)
    at org.apache.dubbo.common.extension.ExtensionLoader.getExtension(ExtensionLoader.java:575)
    at org.apache.dubbo.common.extension.ExtensionLoader.getExtension(ExtensionLoader.java:549)
    at org.apache.dubbo.common.extension.ExtensionLoader.getActivateExtensions(ExtensionLoader.java:451)
    at org.apache.dubbo.common.extension.ExtensionAccessor.getActivateExtensions(ExtensionAccessor.java:51)
    at org.apache.dubbo.rpc.protocol.tri.rest.mapping.DefaultRequestMappingRegistry.init(DefaultRequestMappingRegistry.java:77)
    at org.apache.dubbo.rpc.protocol.tri.rest.mapping.DefaultRequestMappingRegistry.register(DefaultRequestMappingRegistry.java:87)
    at org.apache.dubbo.rpc.protocol.tri.TripleProtocol.export(TripleProtocol.java:124)
    at org.apache.dubbo.rpc.protocol.ProtocolSecurityWrapper.export(ProtocolSecurityWrapper.java:84)
    at org.apache.dubbo.qos.protocol.QosProtocolWrapper.export(QosProtocolWrapper.java:79)
    at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:77)
    at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:61)
    at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.export(ProtocolSerializationWrapper.java:50)
    at org.apache.dubbo.rpc.protocol.InvokerCountWrapper.export(InvokerCountWrapper.java:42)
    at org.apache.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java)
    at org.apache.dubbo.registry.integration.RegistryProtocol.lambda$doLocalExport$3(RegistryProtocol.java:354)
    at org.apache.dubbo.registry.integration.ExporterFactory.lambda$createExporter$0(ExporterFactory.java:31)
    ... 39 common frames omitted
Caused by: java.lang.reflect.InvocationTargetException: null
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.apache.dubbo.common.beans.support.InstantiationStrategy.instantiate(InstantiationStrategy.java:94)
    at org.apache.dubbo.common.extension.ExtensionLoader.createExtensionInstance(ExtensionLoader.java:824)
    at org.apache.dubbo.common.extension.ExtensionLoader.createExtension(ExtensionLoader.java:780)
    ... 55 common frames omitted
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.core.convert.ConversionService' available: expected single matching bean but found 2: mvcConversionService,integrationConversionService
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1273)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveBean(DefaultListableBeanFactory.java:494)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:349)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1181)
    at org.apache.dubbo.rpc.protocol.tri.rest.support.spring.SpringRestToolKit.<init>(SpringRestToolKit.java:82)
    at org.apache.dubbo.rpc.protocol.tri.rest.support.spring.SpringMvcRequestMappingResolver.<init>(SpringMvcRequestMappingResolver.java:44)
    ... 62 common frames omitted

What you expected to happen

The issue seems to be related to the order of bean loading during the startup between dubbo-bom 3.3.0 and spring-boot-starter-web in Spring Boot 2.7.14. The specific reason behind this is currently unknown.

Anything else

No response

Are you willing to submit a pull request to fix on your own?

Code of Conduct

AlbumenJ commented 1 month ago

@oxsean PTAL

oxsean commented 1 month ago

Thanks for the report, fixed in https://github.com/apache/dubbo/pull/14742