Skip to content

[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. #16083

@zhangzhiyu112233

Description

@zhangzhiyu112233

Pre-check

  • I am sure that all the content I provide is in English.

Search before asking

  • I had searched in the issues 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

What you expected to happen

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'.

Image

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.

Image

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'

Anything else

No response

Do you have a (mini) reproduction demo?

  • 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions