You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "zhangzhiyu112233 (via GitHub)" <gi...@apache.org> on 2026/02/13 09:31:38 UTC

[I] [Bug] 初始化泛化调用的consumer无法注册为spring的bean对象 [dubbo]

zhangzhiyu112233 opened a new issue, #16083:
URL: https://github.com/apache/dubbo/issues/16083

   ### 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](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no similar issues.
   
   
   ### Apache Dubbo Component
   
   Java SDK (apache/dubbo)
   
   ### Dubbo Version
   
   dubbo-dubbo-3.2.9  open jdk 8
   
   ### Steps to reproduce this issue
   
   https://github.com/apache/dubbo/tree/dubbo-3.2.9
   但使用dubbo 泛化调用的功能初始化。一个 dubbo consumer的时候,会导致这个consumer无法被注册为spring的bean。
   
   
   
   ### What you expected to happen
   
   比如注册一个泛化调用的consumer 
   
   <img width="1702" height="538" alt="Image" src="https://github.com/user-attachments/assets/f1496bf4-bcf4-49f9-9ee1-34d0018ef301" />
   
   如果这个com.xxx.XxxService 在当前的代码包里存在这类,但是仍然设置 reference.setGeneric(true);会导致代理对象的真实对象为  com.xxx.XxxService 不是 org.apache.dubbo.rpc.service.GenericService
   
   <img width="2244" height="1556" alt="Image" src="https://github.com/user-attachments/assets/edc24837-01b3-45c3-8349-22b0a78f7af0" />
   
    然后spring注入bean的时候就会报错。认为类型不对
   
   会报错Unsatisfied dependency expressed through field 'membershipUserTagTestService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'membershipUserTagTestServiceImpl': Unsatisfied dependency expressed through field 'aeMarketingStrategyShowFacadeGeneric'; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'aeMarketingStrategyShowFacadeGeneric' is expected to be of type 'org.apache.dubbo.rpc.service.GenericService' but was actually of type 'com.sun.proxy.$Proxy524' 
   
   
   ### Anything else
   
   _No response_
   
   ### Do you have a (mini) reproduction demo?
   
   - [x] Yes, I have a minimal reproduction demo to help resolve this issue more effectively!
   
   ### 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](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] [Bug] When Dubbo is used in conjunction with the Spring container, if the Dubbo generic invocation mode is used and the bean is created using the @bean annotation, it can result in the consumer not being registered as a Spring bean. [dubbo]

Posted by "zrlw (via GitHub)" <gi...@apache.org>.
zrlw commented on issue #16083:
URL: https://github.com/apache/dubbo/issues/16083#issuecomment-4073528262

   As for me, Dubbo registers reference beans into the Spring container automatically, the dubbo reference that uses generic mode should be defined as a static variable and be initialized at method ```ApplicationListener#onApplicationEvent``` with parameter ```DubboApplicationStateEvent``` when event#getState returns ```DeployState.STARTED```.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] [Bug] 初始化泛化调用的consumer无法注册为spring的bean对象 [dubbo]

Posted by "zhangzhiyu112233 (via GitHub)" <gi...@apache.org>.
zhangzhiyu112233 commented on issue #16083:
URL: https://github.com/apache/dubbo/issues/16083#issuecomment-3903092962

   When Dubbo is used in conjunction with the Spring container, if the Dubbo generic invocation mode is used and the bean is created using the @Bean annotation, it can result in the consumer not being registered as a Spring bean.
   
   For example, when registering a consumer using Dubbo's generic invocation mode, if the @Bean annotation is used to create this bean, it can result in the consumer not being registered as a Spring bean.
   
   The `reference.get()` method returns a proxy object, and the `tClass` of this proxy object is `'com.xxx.XxxService'`.
   
   <img width="1586" height="730" alt="Image" src="https://github.com/user-attachments/assets/93a66446-55c5-436b-b893-601cf993cf95" />
   
   The reference.get() method returns a proxy object, and the tClass of this proxy object is 'com.xxx.XxxService'. Additionally, this bean is injected using @Autowired and @Qualifier as follows:
   @Autowired
   @Qualifier("XxxService")
   private GenericService xxxService;
   
   The code for generating a proxy object by Dubbo is as follows: If com.xxx.XxxService exists in the current code package, but reference.setGeneric(true); is still set, it will cause the actual object of the proxy to be com.xxx.XxxService instead of org.apache.dubbo.rpc.service.GenericService.
   
   <img width="2244" height="1556" alt="Image" src="https://github.com/user-attachments/assets/453ea8aa-e6fc-4900-92e5-2784502689bb" />
   
   spring start error text e.g :
   
   Unsatisfied dependency expressed through field 'membershipUserTagTestService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'membershipUserTagTestServiceImpl': Unsatisfied dependency expressed through field 'aeMarketingStrategyShowFacadeGeneric'; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'aeMarketingStrategyShowFacadeGeneric' is expected to be of type 'org.apache.dubbo.rpc.service.GenericService' but was actually of type 'com.sun.proxy.$Proxy524'


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] [Bug] 初始化泛化调用的consumer无法注册为spring的bean对象 [dubbo]

Posted by "zrlw (via GitHub)" <gi...@apache.org>.
zrlw commented on issue #16083:
URL: https://github.com/apache/dubbo/issues/16083#issuecomment-3901238461

   > I am sure that all the content I provide is in English.
   
   pls rewrite all the contents in Englisth


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] [Bug] 初始化泛化调用的consumer无法注册为spring的bean对象 [dubbo]

Posted by "zhangzhiyu112233 (via GitHub)" <gi...@apache.org>.
zhangzhiyu112233 commented on issue #16083:
URL: https://github.com/apache/dubbo/issues/16083#issuecomment-3903096556

   When Dubbo is used in conjunction with the Spring container, if the Dubbo generic invocation mode is used and the bean is created using the @bean annotation, it can result in the consumer not being registered as a Spring bean.
   
   For example, when registering a consumer using Dubbo's generic invocation mode, if the @bean annotation is used to create this bean, it can result in the consumer not being registered as a Spring bean.
   
   The reference.get() method returns a proxy object, and the tClass of this proxy object is 'com.xxx.XxxService'.
   
   <img width="1586" height="730" alt="Image" src="https://github.com/user-attachments/assets/73dd84f2-0fba-4c87-9b81-d3dd43d38231" />
   
   The reference.get() method returns a proxy object, and the tClass of this proxy object is 'com.xxx.XxxService'. Additionally, this bean is injected using @Autowired and @qualifier as follows:
   @Autowired
   @qualifier("XxxService")
   private GenericService xxxService;
   
   The code for generating a proxy object by Dubbo is as follows: If com.xxx.XxxService exists in the current code package, but reference.setGeneric(true); is still set, it will cause the actual object of the proxy to be com.xxx.XxxService instead of org.apache.dubbo.rpc.service.GenericService.
   
   <img width="2244" height="1556" alt="Image" src="https://github.com/user-attachments/assets/a6144ec6-f730-4a4c-a0c1-a6fe9bceba84" />
   
   spring start error text e.g :
   
   Unsatisfied dependency expressed through field 'membershipUserTagTestService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'membershipUserTagTestServiceImpl': Unsatisfied dependency expressed through field 'aeMarketingStrategyShowFacadeGeneric'; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'aeMarketingStrategyShowFacadeGeneric' is expected to be of type 'org.apache.dubbo.rpc.service.GenericService' but was actually of type 'com.sun.proxy.$Proxy524'


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] [Bug] 初始化泛化调用的consumer无法注册为spring的bean对象 [dubbo]

Posted by "jk-tonycui (via GitHub)" <gi...@apache.org>.
jk-tonycui commented on issue #16083:
URL: https://github.com/apache/dubbo/issues/16083#issuecomment-3896292067

   I would like to work on this issue. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org