dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

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

Open paxxie2 opened this issue 1 year ago • 5 comments

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

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<String, BillCompareConfigInfo> 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&timestamp=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

paxxie2 avatar Jul 16 '24 14:07 paxxie2

Sorry, this is a new feature in version 3.3, which is not directly supported in version 3.2 at this time.By the way, the official version 3.3 is expected to be released by the end of this month @xgj2440620200

heliang666s avatar Jul 17 '24 10:07 heliang666s

Follow-up:

This problem still exists in version 3.3, dubbo 3.3.0-beta.4

Create a new branch based 3.3.0-beta.2 that will work with remove all the rest functionality.

Is it possible to turn on a switch to disable rest?

wcy666103 avatar Jul 18 '24 07:07 wcy666103

Has it been finally resolved? Is it a version issue

wangqing-github avatar Sep 13 '24 08:09 wangqing-github

This SPI(org.apache.dubbo.registry.client.metadata.ServiceInstanceNotificationCustomizer) causes this problem. Version 3.3.1 has removed this SPI. Is there a fix planned for version 3.2.x? @heliang666s

kanjianhaian avatar Oct 22 '24 13:10 kanjianhaian

Sorry, version 3.2.x no longer does breaking change, you can change to version 3.3, 3.3 has been officially released, or you can manually delete and then compile and package. @kanjianhaian

heliang666s avatar Oct 23 '24 04:10 heliang666s