apache / apache/dubbo

[Bug] only support [jax-rs, spring-webmvc] annotation

Open
#14,446 5 comments 0 reactions 0 assignees View on GitHub
component/need-triage type/need-triage
Dominant language
Java
Stars
41.6k
Forks
26.4k
Avg merge
15h 13m
Merged PRs (30d)
4

Description

### 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 java 3.2.10~3.2.14, OpenJdk 17, Spring Boot 2.7.6, mac

### Steps to reproduce this issue

1. diagrammatic sketch
![image](https://github.com/user-attachments/assets/1f138bbe-6245-4062-9b7f-d840d07183d1)

explain: java process C ,use Dubbo 2.7, log-facade declaration interface, log-service implements log-facade, log-service declare @DubboService. log-client new a class with @Component\ spring boot auto-configure, use @DubboReference to quote log-facade,and add some function. java process B quote log-facade by maven. java process A , use Dubbo 3.2.10, quote log-facade by maven.
2. simple code
`
// 2.1 log-facade
public interface OperateLogFacade {

/**
* 保存操作日志
* @param operateLogDto
*/
void save(OperateLogDto operateLogDto);
}

// 2.2 dubbo log-service
@Slf4j
@DubboService
public class OperateLogFacadeImpl implements OperateLogFacade {

// spring service bean
@Autowired
private OperateLogService operateLogService;

@Autowired
private MongoTemplate mongoTemplate;

@Autowired
private CompareHelper compareHelper;

@Override
public void save(OperateLogDto operateLogDto) {
if(Objects.isNull(operateLogDto)) {
return;
}
operateLogService.save(CachedBeanCopier.copy(operateLogDto, OperateLog.class));
}
}

// 2.3 log-client, proxy
@Slf4j(topic = "billLog")
@Component
public class BillLogServer {

@DubboReference
// @Autowired
private BillLogFacade billLogFacade;

public void saveBillLog(CompareVersionStrategy compareVersionStrategy, Object t) {
Map billCompareMap = parseClass(t);
compareVersionStrategy.setTenant(LogRecordContext.TENANT_ID);
compareVersionStrategy.setOperatorId(ReqCtxUtil.getUid());
compareVersionStrategy.setOperatorName(ReqCtxUtil.getFlowerName());
billLogFacade.saveBillLog(compareVersionStrategy, t, billCompareMap);
}
}

// 2.4 log-client,spring boot auto-configure
@Order(2)
@Slf4j
@Configuration
@ConditionalOnWebApplication
@ConditionalOnProperty(value = "gaia.log.enable", matchIfMissing = true)
@EnableLogRecord
public class LogAutoConfiguration implements EnvironmentAware {

private Environment environment;

public LogAutoConfiguration(){
log.info("...... === LogAutoConfiguration 1 === ....... ");
}

@Bean
public OperateLogServer operateLogServer(){
return new OperateLogServer();
}
}
//2.5 consumer, java process A
@Slf4j
@Service
public class SsoAccountBiz {

@DubboReference
private SsoAccountFacade ssoAccountFacade;
}
`
3. java Process A , exception log
`
2024-07-16 21:33:13.221 [0f8d820e60bc4133864c2ffe93035f5a] [main] ERROR o.a.d.r.c.ServiceDiscoveryRegistryDirectory:? - [DUBBO] Failed to refer invoker for interface:interface com.sd.sso.facade.api.SsoAccountFacade,url:(DefaultServiceInstance{serviceName='sd-sso-server', host='10.244.45.71', port=6082, enabled=true, healthy=true, metadata={dubbo.metadata-service.urls=[ "dubbo://10.244.45.71:20905/com.alibaba.cloud.dubbo.service.DubboMetadataService?anyhost=true&application=sd-sso-server&bind.ip=10.244.45.71&bind.port=20905&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=sd-sso-server&interface=com.alibaba.cloud.dubbo.service.DubboMetadataService&metadata-type=remote&methods=getAllServiceKeys,getServiceRestMetadata,getExportedURLs,getAllExportedURLs&pid=1&qos.enable=false&release=2.7.13&revision=2.2.7.RELEASE&service.name=ServiceBean:sd-sso-server/com.alibaba.cloud.dubbo.service.DubboMetadataService:1.0.0&side=provider&timeout=3000×tamp=1721134954977&version=1.0.0" ], dubbo.metadata.revision=0480A7128A4CA18A866438EA0057DE4E, dubbo.protocols.dubbo.port=20905, preserved.register.source=SPRING_CLOUD}}, service{name='com.sd.sso.facade.api.SsoAccountFacade',group='betaA',version='null',protocol='null',port='6082',params={},})service is: interface com.sd.sso.facade.api.SsoAccountFacade, only support [jax-rs, spring-webmvc] annotation, dubbo version: 3.2.14, current host: 192.168.28.252, error code: 4-3. This may be caused by , go to https://dubbo.apache.org/faq/4/3 to find instructions.
org.apache.dubbo.rpc.protocol.rest.exception.CodeStyleNotSupportException: service is: interface com.sd.sso.facade.api.SsoAccountFacade, only support [jax-rs, spring-webmvc] annotation
at org.apache.dubbo.rpc.protocol.rest.annotation.metadata.MetadataResolver.resolveConsumerServiceMetadata(MetadataResolver.java:54)
at org.apache.dubbo.rpc.protocol.rest.RestProtocol.protocolBindingRefer(RestProtocol.java:134)
at org.apache.dubbo.rpc.protocol.AbstractProtocol.refer(AbstractProtocol.java:137)
at org.apache.dubbo.rpc.protocol.ProtocolSecurityWrapper.refer(ProtocolSecurityWrapper.java:112)
at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:86)
at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:85)
at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:75)
at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.refer(ProtocolSerializationWrapper.java:55)
at org.apache.dubbo.rpc.protocol.InvokerCountWrapper.refer(InvokerCountWrapper.java:50)
at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java)
at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.toInvokers(ServiceDiscoveryRegistryDirectory.java:490)
at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.refreshInvoker(ServiceDiscoveryRegistryDirectory.java:356)
at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.refreshOverrideAndInvoker(ServiceDiscoveryRegistryDirectory.java:219)
at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.notify(ServiceDiscoveryRegistryDirectory.java:211)
at org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener.addListenerAndNotify(ServiceInstancesChangedListener.java:269)
at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribeURLs(ServiceDiscoveryRegistry.java:362)
at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.doSubscribe(ServiceDiscoveryRegistry.java:243)
at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribe(ServiceDiscoveryRegistry.java:194)
at org.apache.dubbo.registry.ListenerRegistryWrapper.subscribe(ListenerRegistryWrapper.java:87)
at org.apache.dubbo.registry.integration.DynamicDirectory.subscribe(DynamicDirectory.java:186)
at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.subscribe(ServiceDiscoveryRegistryDirectory.java:151)
at org.apache.dubbo.registry.integration.RegistryProtocol.doCreateInvoker(RegistryProtocol.java:639)
at org.apache.dubbo.registry.integration.InterfaceCompatibleRegistryProtocol.getServiceDiscoveryInvoker(InterfaceCompatibleRegistryProtocol.java:66)
at org.apache.dubbo.registry.client.migration.MigrationInvoker.refreshServiceDiscoveryInvoker(MigrationInvoker.java:458)
at org.apache.dubbo.registry.client.migration.MigrationInvoker.migrateToApplicationFirstInvoker(MigrationInvoker.java:256)
at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.refreshInvoker(MigrationRuleHandler.java:78)
at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.doMigrate(MigrationRuleHandler.java:62)
at org.apache.dubbo.registry.client.migration.MigrationRuleListener.onRefer(MigrationRuleListener.java:285)
at org.apache.dubbo.registry.integration.RegistryProtocol.interceptInvoker(RegistryProtocol.java:602)
at org.apache.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:566)
at org.apache.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:547)
at org.apache.dubbo.rpc.protocol.ProtocolSecurityWrapper.refer(ProtocolSecurityWrapper.java:112)
at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:83)
at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:85)
at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:72)
at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.refer(ProtocolSerializationWrapper.java:55)
at org.apache.dubbo.rpc.protocol.InvokerCountWrapper.refer(InvokerCountWrapper.java:48)
at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java)
at org.apache.dubbo.config.ReferenceConfig.createInvoker(ReferenceConfig.java:656)
at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:486)
at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:370)
at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:238)
at org.apache.dubbo.config.utils.SimpleReferenceCache.get(SimpleReferenceCache.java:140)
at org.apache.dubbo.config.deploy.DefaultModuleDeployer.lambda$referServices$6(DefaultModuleDeployer.java:545)
at java.base/java.util.concurrent.ConcurrentHashMap$ValuesView.forEach(ConcurrentHashMap.java:4780)
at org.apache.dubbo.config.deploy.DefaultModuleDeployer.referServices(DefaultModuleDeployer.java:517)
at org.apache.dubbo.config.deploy.DefaultModuleDeployer.startSync(DefaultModuleDeployer.java:183)
at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:156)
at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onContextRefreshedEvent(DubboDeployApplicationListener.java:157)
at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:143)
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:938)
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.sd.strategy.web.WebApplication.main(WebApplication.java:29)
`

### What you expected to happen

I expected no exception happen. If I upgrade dubbo 3.2.10 to 3.3.0-beta.4 , java process A would had no exception log.

### Anything else

We do not want upgrade dubbo to beta.4 , is there any solution?

### 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)

Contributor guide

Open the contributing guide

Research direction

Start with org.apache.dubbo.rpc.protocol.rest.annotation.metadata.MetadataResolver.resolveConsumerServiceMetadata, then read RestProtocol.protocolBindingRefer and the surrounding stack trace. Compare the behavior in Dubbo 3.2.14 with 3.3.0-beta.4 using the SsoAccountFacade reference scenario. Done means the shown consumer no longer raises CodeStyleNotSupportException while supported REST annotation handling remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
backend-api-design, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.