开发者社区 > 云原生 > 正文

dubbo 3.1.7扩展实例无法实例化

dubbo version: 3.1.7 nacos version:2.2.0

yml `

spring: application: name: rpc server: port: 9001 dubbo: application: name: rpc qos-enable: true qos-port: 44444 qos-accept-foreign-ip: false protocol: name: dubbo port: -1 registry: address: nacos://localhost:8848?username=nacos&password=nacos config-center: address: nacos://localhost:8848?username=nacos&password=nacos metadata-report: address: nacos://localhost:8848?username=nacos&password=nacos

spring: application: name: consumer server: port: 9000 dubbo: application: name: consumer qos-accept-foreign-ip: false qos-enable: true qos-port: 33333 scan: base-packages: com.xxx protocol: name: dubbo port: -1 registry: address: nacos://localhost:8848?username=nacos&password=nacos config-center: address: nacos://localhost:8848?username=nacos&password=nacos metadata-report: address: nacos://localhost:8848?username=nacos&password=nacos ` 报错日志 2023-03-16 16:23:14.063 ERROR 15300 --- [ncesChangeEvent] .d.r.c.ServiceDiscoveryRegistryDirectory : [DUBBO] Failed to refer invoker for interface:interface com.modules.service.DemoService,url:(DefaultServiceInstance{serviceName='rpc', host='172.0.4.184', port=9001, enabled=true, healthy=true, metadata={preserved.register.source=SPRING_CLOUD}}, service{name='com.modules.service.DemoService',group='null',version='null',protocol='null',port='9001',params={},})Extension instance (name: rest, class: interface org.apache.dubbo.rpc.Protocol) couldn't be instantiated: null, dubbo version: 3.1.7, current host: 172.0.4.184, error code: 4-3. This may be caused by , go to https://dubbo.apache.org/faq/4/3 to find instructions.

java.lang.IllegalStateException: Extension instance (name: rest, class: interface org.apache.dubbo.rpc.Protocol) couldn't be instantiated: null at org.apache.dubbo.common.extension.ExtensionLoader.createExtension(ExtensionLoader.java:806) ~[dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.common.extension.ExtensionLoader.getExtension(ExtensionLoader.java:561) ~[dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.common.extension.ExtensionLoader.getExtension(ExtensionLoader.java:535) ~[dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java) ~[dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.toInvokers(ServiceDiscoveryRegistryDirectory.java:352) [dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.refreshInvoker(ServiceDiscoveryRegistryDirectory.java:254) [dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.refreshOverrideAndInvoker(ServiceDiscoveryRegistryDirectory.java:182) [dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.notify(ServiceDiscoveryRegistryDirectory.java:176) [dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener.lambda$notifyAddressChanged$9(ServiceInstancesChangedListener.java:417) [dubbo-3.1.7.jar:3.1.7] at java.util.concurrent.ConcurrentHashMap.forEach(ConcurrentHashMap.java:1597) ~[na:1.8.0_331] at org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener.notifyAddressChanged(ServiceInstancesChangedListener.java:410) [dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener.doOnEvent(ServiceInstancesChangedListener.java:217) [dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener.onEvent(ServiceInstancesChangedListener.java:113) [dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.registry.nacos.NacosServiceDiscovery.handleEvent(NacosServiceDiscovery.java:231) ~[dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.registry.nacos.NacosServiceDiscovery.access$000(NacosServiceDiscovery.java:64) ~[dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.registry.nacos.NacosServiceDiscovery$NacosEventListener.onEvent(NacosServiceDiscovery.java:202) ~[dubbo-3.1.7.jar:3.1.7] at com.alibaba.nacos.client.naming.event.InstancesChangeNotifier.onEvent(InstancesChangeNotifier.java:126) ~[nacos-client-2.2.0.jar:na] at com.alibaba.nacos.client.naming.event.InstancesChangeNotifier.onEvent(InstancesChangeNotifier.java:42) ~[nacos-client-2.2.0.jar:na] at com.alibaba.nacos.common.notify.DefaultPublisher.lambda$notifySubscriber$0(DefaultPublisher.java:199) ~[nacos-client-2.2.0.jar:na] at com.alibaba.nacos.common.notify.DefaultPublisher.notifySubscriber(DefaultPublisher.java:206) ~[nacos-client-2.2.0.jar:na] at com.alibaba.nacos.common.notify.DefaultPublisher.receiveEvent(DefaultPublisher.java:190) ~[nacos-client-2.2.0.jar:na] at com.alibaba.nacos.common.notify.DefaultPublisher.openEventHandler(DefaultPublisher.java:112) ~[nacos-client-2.2.0.jar:na] at com.alibaba.nacos.common.notify.DefaultPublisher.run(DefaultPublisher.java:95) ~[nacos-client-2.2.0.jar:na] Caused by: java.lang.reflect.InvocationTargetException: null at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_331] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_331] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_331] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_331] at org.apache.dubbo.common.beans.support.InstantiationStrategy.instantiate(InstantiationStrategy.java:94) ~[dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.common.extension.ExtensionLoader.createExtensionInstance(ExtensionLoader.java:811) ~[dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.common.extension.ExtensionLoader.createExtension(ExtensionLoader.java:772) ~[dubbo-3.1.7.jar:3.1.7] ... 22 common frames omitted Caused by: java.lang.NoClassDefFoundError: javax/ws/rs/ProcessingException at org.apache.dubbo.rpc.protocol.rest.RestProtocol.(RestProtocol.java:80) ~[dubbo-3.1.7.jar:3.1.7] ... 29 common frames omitted

新增依赖

org.jboss.resteasy resteasy-client 3.0.20.Final 解决了上述报错又有了新的错误,我想这是Dubbo RestProtocol机制导致的吧? 而我并不使用Dubbo RestProtocol机制,那么我应该怎么解决这个问题?

2023-03-16 18:03:27.850 ERROR 11800 --- [ternal.notifier] .d.r.c.ServiceDiscoveryRegistryDirectory : [DUBBO] Failed to refer invoker for interface:interface com.rpc.modules.service.DemoService,url:(DefaultServiceInstance{serviceName='rpc', host='172.0.4.184', port=9001, enabled=true, healthy=true, metadata={preserved.register.source=SPRING_CLOUD}}, service{name='com.rpc.modules.service.DemoService',group='null',version='null',protocol='null',port='9001',params={},})RESTEASY004600: You must use at least one, but no more than one http method annotation on: public abstract java.lang.String com.rpc.modules.service.DemoService.abc(), dubbo version: 3.1.7, current host: 172.0.4.184, error code: 4-3. This may be caused by , go to https://dubbo.apache.org/faq/4/3 to find instructions.

java.lang.RuntimeException: RESTEASY004600: You must use at least one, but no more than one http method annotation on: public abstract java.lang.String com.rpc.modules.service.DemoService.abc() at org.jboss.resteasy.client.jaxrs.ProxyBuilder.createClientInvoker(ProxyBuilder.java:87) ~[resteasy-client-3.0.20.Final.jar:3.0.20.Final] at org.jboss.resteasy.client.jaxrs.ProxyBuilder.proxy(ProxyBuilder.java:63) ~[resteasy-client-3.0.20.Final.jar:3.0.20.Final] at org.jboss.resteasy.client.jaxrs.ProxyBuilder.build(ProxyBuilder.java:131) ~[resteasy-client-3.0.20.Final.jar:3.0.20.Final] at org.jboss.resteasy.client.jaxrs.internal.ClientWebTarget.proxy(ClientWebTarget.java:74) ~[resteasy-client-3.0.20.Final.jar:3.0.20.Final] at org.apache.dubbo.rpc.protocol.rest.RestProtocol.doRefer(RestProtocol.java:162) ~[dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.rpc.protocol.AbstractProxyProtocol.protocolBindingRefer(AbstractProxyProtocol.java:110) ~[dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.rpc.protocol.AbstractProtocol.refer(AbstractProtocol.java:134) ~[dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:77) ~[dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.rpc.protocol.ProtocolSecurityWrapper.refer(ProtocolSecurityWrapper.java:107) ~[dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:83) ~[dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:74) ~[dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.refer(ProtocolSerializationWrapper.java:52) ~[dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java) ~[dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.toInvokers(ServiceDiscoveryRegistryDirectory.java:352) [dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.refreshInvoker(ServiceDiscoveryRegistryDirectory.java:254) [dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.refreshOverrideAndInvoker(ServiceDiscoveryRegistryDirectory.java:182) [dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.notify(ServiceDiscoveryRegistryDirectory.java:176) [dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener.addListenerAndNotify(ServiceInstancesChangedListener.java:237) [dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribeURLs(ServiceDiscoveryRegistry.java:326) [dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry$DefaultMappingListener.onEvent(ServiceDiscoveryRegistry.java:386) [dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.metadata.store.nacos.NacosMetadataReport$MappingDataListener.lambda$process$0(NacosMetadataReport.java:514) [dubbo-3.1.7.jar:3.1.7] at java.lang.Iterable.forEach(Iterable.java:75) ~[na:1.8.0_331] at org.apache.dubbo.metadata.store.nacos.NacosMetadataReport$MappingDataListener.process(NacosMetadataReport.java:514) [dubbo-3.1.7.jar:3.1.7] at org.apache.dubbo.metadata.store.nacos.NacosMetadataReport$NacosConfigListener.lambda$innerReceive$0(NacosMetadataReport.java:445) ~[dubbo-3.1.7.jar:3.1.7] at java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:895) ~[na:1.8.0_331] at java.util.concurrent.CopyOnWriteArraySet.forEach(CopyOnWriteArraySet.java:404) ~[na:1.8.0_331] at org.apache.dubbo.metadata.store.nacos.NacosMetadataReport$NacosConfigListener.innerReceive(NacosMetadataReport.java:445) ~[dubbo-3.1.7.jar:3.1.7] at com.alibaba.nacos.api.config.listener.AbstractSharedListener.receiveConfigInfo(AbstractSharedListener.java:40) ~[nacos-client-2.2.0.jar:na] at com.alibaba.nacos.client.config.impl.CacheData.lambda$safeNotifyListener$1(CacheData.java:334) ~[nacos-client-2.2.0.jar:na] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_331] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_331] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_331] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_331] at java.lang.Thread.run(Thread.java:750) ~[na:1.8.0_331]

原提问者GitHub用户chenglutao

展开
收起
大圣东游 2023-05-11 15:45:08 3957 0
1 条回答
写回答
取消 提交回答
  • dubbo 和 Spring Cloud Alibaba 的分组要分开,不要使用同一个分组名,这样会导致错误订阅到 Spring Cloud 的应用,使用了 Rest 协议

    原回答者GitHub用户chenglutao

    2023-05-12 10:16:37
    赞同 展开评论 打赏

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

相关电子书

更多
Dubbo开源现状与2.7规划 立即下载
Dubbo分布式服务治理实战 立即下载
《Dubbo 3.0 前瞻》 立即下载