Pre-check
- [x] I am sure that all the content I provide is in English.
Search before asking
- [x] I had searched in the issues and found no similar issues.
Apache Dubbo Component
Java Samples (apache/dubbo-samples)
Dubbo Version
Dubbo 3.3.4, SpringBoot 2.7.18, Corretto 1.8.0_452
Steps to reproduce this issue
Modify the samples code: ```[java] /** * stub-consumer/StubConsumer * / @DubboReference(check=false, stub="org.apache.dubbo.samples.stub.DemoServiceStub", onconnect = "print", interfaceName = "org.apache.dubbo.samples.stub.DemoService") private DemoService demoService;
```[stub-interface]
/**
* stub-interface/DemoServiceStub
* /
public void print() {
logger.info("onconnect.");
}
then start zk, provider, consumer. and consumer print error log:
17:25:50.205 |-ERROR [main] pc.proxy.wrapper.StubProxyFactoryWrapper: -| [DUBBO] export a stub service error., dubbo version: 3.3.4, current host: 192.168.31.200, error code: 3-2. This may be caused by , go to https://dubbo.apache.org/faq/3/2 to find instructions.
java.lang.IllegalStateException: No such extension org.apache.dubbo.rpc.Protocol by name consumer, no related exception was found, please check whether related SPI module is missing.
at org.apache.dubbo.common.extension.ExtensionLoader.findException(ExtensionLoader.java:768) ~[dubbo-3.3.4.jar:3.3.4]
at org.apache.dubbo.common.extension.ExtensionLoader.createExtension(ExtensionLoader.java:775) ~[dubbo-3.3.4.jar:3.3.4]
at org.apache.dubbo.common.extension.ExtensionLoader.getExtension(ExtensionLoader.java:575) ~[dubbo-3.3.4.jar:3.3.4]
at org.apache.dubbo.common.extension.ExtensionLoader.getExtension(ExtensionLoader.java:549) ~[dubbo-3.3.4.jar:3.3.4]
at org.apache.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java) ~[dubbo-3.3.4.jar:3.3.4]
at org.apache.dubbo.rpc.proxy.wrapper.StubProxyFactoryWrapper.export(StubProxyFactoryWrapper.java:139) ~[dubbo-3.3.4.jar:3.3.4]
at org.apache.dubbo.rpc.proxy.wrapper.StubProxyFactoryWrapper.getProxy(StubProxyFactoryWrapper.java:99) ~[dubbo-3.3.4.jar:3.3.4]
at org.apache.dubbo.rpc.ProxyFactory$Adaptive.getProxy(ProxyFactory$Adaptive.java) ~[dubbo-3.3.4.jar:3.3.4]
at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:522) ~[dubbo-3.3.4.jar:3.3.4]
at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:383) ~[dubbo-3.3.4.jar:3.3.4]
at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:244) ~[dubbo-3.3.4.jar:3.3.4]
at org.apache.dubbo.config.utils.SimpleReferenceCache.get(SimpleReferenceCache.java:140) ~[dubbo-3.3.4.jar:3.3.4]
at org.apache.dubbo.config.deploy.DefaultModuleDeployer.lambda$referServices$6(DefaultModuleDeployer.java:567) ~[dubbo-3.3.4.jar:3.3.4]
at java.util.concurrent.ConcurrentHashMap$ValuesView.forEach(ConcurrentHashMap.java:4705) ~[?:1.8.0_452]
at org.apache.dubbo.config.deploy.DefaultModuleDeployer.referServices(DefaultModuleDeployer.java:539) ~[dubbo-3.3.4.jar:3.3.4]
at org.apache.dubbo.config.deploy.DefaultModuleDeployer.startSync(DefaultModuleDeployer.java:186) ~[dubbo-3.3.4.jar:3.3.4]
at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:159) ~[dubbo-3.3.4.jar:3.3.4]
at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onContextRefreshedEvent(DubboDeployApplicationListener.java:167) ~[dubbo-3.3.4.jar:3.3.4]
at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:153) ~[dubbo-3.3.4.jar:3.3.4]
at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:52) ~[dubbo-3.3.4.jar:3.3.4]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:178) ~[spring-context-5.3.31.jar:5.3.31]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:171) ~[spring-context-5.3.31.jar:5.3.31]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:145) ~[spring-context-5.3.31.jar:5.3.31]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:429) ~[spring-context-5.3.31.jar:5.3.31]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:386) ~[spring-context-5.3.31.jar:5.3.31]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:949) ~[spring-context-5.3.31.jar:5.3.31]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:594) ~[spring-context-5.3.31.jar:5.3.31]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[spring-boot-2.7.18.jar:2.7.18]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:409) ~[spring-boot-2.7.18.jar:2.7.18]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.18.jar:2.7.18]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) ~[spring-boot-2.7.18.jar:2.7.18]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1289) ~[spring-boot-2.7.18.jar:2.7.18]
at org.apache.dubbo.samples.stub.consumer.StubConsumer.main(StubConsumer.java:44) ~[classes/:?]
What you expected to happen
Consumer can work normally
Anything else
No response
Are you willing to submit a pull request to fix on your own?
- [ ] Yes I am willing to submit a pull request on my own!
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Comment From: fantiq
Set protocol
parameters on annotations,like this:
@DubboReference(check=false,
protocol="dubbo",
stub="org.apache.dubbo.samples.stub.DemoServiceStub",
onconnect = "print",
interfaceName = "org.apache.dubbo.samples.stub.DemoService")
private DemoService demoService;
Comment From: kbac001
Set
protocol
parameters on annotations,like this:@DubboReference(check=false, protocol="dubbo", stub="org.apache.dubbo.samples.stub.DemoServiceStub", onconnect = "print", interfaceName = "org.apache.dubbo.samples.stub.DemoService") private DemoService demoService;
Thanks a lot it worked, but why? I have defined dubbo.consumer.protocal: dubbo
in application.yml but it doesn't work.
Comment From: fantiq
Set
protocol
parameters on annotations,like this: @DubboReference(check=false, protocol="dubbo", stub="org.apache.dubbo.samples.stub.DemoServiceStub", onconnect = "print", interfaceName = "org.apache.dubbo.samples.stub.DemoService") private DemoService demoService;Thanks a lot it worked, but why? I have defined
dubbo.consumer.protocal: dubbo
in application.yml but it doesn't work.
can u please provider a complete example?
Comment From: kbac001
Set
protocol
parameters on annotations,like this: @DubboReference(check=false, protocol="dubbo", stub="org.apache.dubbo.samples.stub.DemoServiceStub", onconnect = "print", interfaceName = "org.apache.dubbo.samples.stub.DemoService") private DemoService demoService;Thanks a lot it worked, but why? I have defined
dubbo.consumer.protocal: dubbo
in application.yml but it doesn't work.can u please provider a complete example?
Sorry I don’t have more examples, but let me try to explain. From what I understand, if the protocol
field isn’t set in @DubboReference
, Dubbo will use the value from the config file — like dubbo.consumer.protocol
or dubbo.protocol.name
. And that works fine in most cases when stub.event
is not involved.(In this issue, when I use onconnect
, it automatically sets stub.event
to true
.)
And that’s where my question comes in. Why is stub.event
treated differently? When I use onconnect
or ondisconnect
, why do I have to explicitly set the protocol
field in @DubboReference
for it to work? It’s not really explained in the official docs, so I’m not sure if this is expected behavior or a bug.
Comment From: fantiq
Set
protocol
parameters on annotations,like this: @DubboReference(check=false, protocol="dubbo", stub="org.apache.dubbo.samples.stub.DemoServiceStub", onconnect = "print", interfaceName = "org.apache.dubbo.samples.stub.DemoService") private DemoService demoService;Thanks a lot it worked, but why? I have defined
dubbo.consumer.protocal: dubbo
in application.yml but it doesn't work.can u please provider a complete example?
Sorry I don’t have more examples, but let me try to explain. From what I understand, if the
protocol
field isn’t set in@DubboReference
, Dubbo will use the value from the config file — likedubbo.consumer.protocol
ordubbo.protocol.name
. And that works fine in most cases whenstub.event
is not involved.(In this issue, when I useonconnect
, it automatically setsstub.event
totrue
.)And that’s where my question comes in. Why is
stub.event
treated differently? When I useonconnect
orondisconnect
, why do I have to explicitly set theprotocol
field in@DubboReference
for it to work? It’s not really explained in the official docs, so I’m not sure if this is expected behavior or a bug.
the correct configuration item is dubbo.consumer.protocol: dubbo
. You can use it in the configuration file instead of setting it in the annotations.
If you have set the onconnect
or ondisconnect
options,proxy clients need to perform service export to listen for local network events, the export
process need the protocol value.
can look at org.apache.dubbo.rpc.proxy.wrapper.StubProxyFactoryWrapper#getProxy(org.apache.dubbo.rpc.Invoker<T>, boolean)
and org.apache.dubbo.remoting.exchange.support.ExchangeHandlerAdapter#invoke