Error[8]: Undefined offset: 53, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

Dubbo 3.0.3 + Nacos 2.0.3 + Spring Boot 2.3.6.RELEASE 整合及使用时遇到的问题

Dubbo 3.0.3 + Nacos 2.0.3 + spring boot 2.3.6.RELEASE 整合中遇到的问题

Dubbo 3.0.3 + Nacos 2.0.3 + spring boot 2.3.6.RELEASE 整合

由于公司的一些老项目使用的rpc(是由HTTPClient封装的一个调用工具包),考虑到性能低,维护起来又极其难受。在众多rpc框架中对比发现,加上dubbo又推出了3.0版本,再加上目前各大企业都是采用dubbo作为rpc框架。故推翻现有的rpc,采用dubbo 3.0.3 来替换项目中的rpc框架,阅读各大网站、论坛,帖子发现dubbo 2.x版大多数使用的还是zookeeper作为rpc的注册中心,由于之前学习过spring cloud H版后发现 nacos 做为服务注册中心也是一个很不错的选择,所以此次升级也是采用了nacos 2.0

项目框架搭建 服务提供者

pom.xml



    4.0.0

    org.example
    demo-provider
    1.0.0-SNAPSHOT

    
        org.springframework.boot
        spring-boot-dependencies
        2.3.6.RELEASE
    

    
        1.8
        UTF-8
        UTF-8
        2.3.6.RELEASE
        3.4.1
        1.1.21
        5.1.47
        3.0.3
        1.2.9
    

    

        
        
            org.example
            demo-interface
            1.0.0-SNAPSHOT
        

        
        
            org.springframework.boot
            spring-boot-starter-web
        
        
            org.springframework.boot
            spring-boot-starter-actuator
        
        
            org.springframework.boot
            spring-boot-starter-validation
        
        
            org.springframework.boot
            spring-boot-configuration-processor
        

        
        
            org.apache.dubbo
            dubbo-spring-boot-starter
            ${dubbo.version}
        
        
        
            org.apache.dubbo
            dubbo-registry-nacos
            ${dubbo.version}
        

        
        
            mysql
            mysql-connector-java
        
        
        
            com.alibaba
            druid-spring-boot-starter
            ${druid-spring-boot.version}
        
        
        
            com.baomidou
            mybatis-plus-boot-starter
            ${mybatis-plus-spring-boot.version}
        

        
        
            org.springframework.boot
            spring-boot-devtools
            runtime
            true
        

    

    
        demo-provider
        
            
                org.apache.maven.plugins
                maven-compiler-plugin
                
                    ${java.version}
                    ${java.version}
                    ${project.build.sourceEncoding}
                
            
            
                org.springframework.boot
                spring-boot-maven-plugin
                
                    true
                    true
                    org.example.DemoApplication
                
                
                    
                        repackage
                        
                            repackage
                        
                    
                
            
        
    


application.yml

server:
  port: 8080

spring:
  application:
    name: dubbo-demo-provider
  jackson:
    time-zone: GMT+8
    date-format: yyyy-MM-dd HH:mm:ss
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/demo?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&autoReconnectForPools=true&useSSL=false
    username: root
    password: 123456
    druid:
      initialSize: 5
      minIdle: 5
      maxActive: 20
      # 配置获取连接等待超时的时间
      maxWait: 60000
      # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
      timeBetweenEvictionRunsMillis: 60000
      # 配置一个连接在池中最小生存的时间,单位是毫秒
      minEvictableIdleTimeMillis: 300000
      validationQuery: select 'x'
      testWhileIdle: true
      testOnBorrow: false
      testOnReturn: false
      # 打开PSCache,并且指定每个连接上PSCache的大小
      poolPreparedStatements: true
      maxPoolPreparedStatementPerConnectionSize: 20
      # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
      filters: stat,wall,slf4j
      # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
      connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000

dubbo:
  application:
    name: dubbo-demo-provider
    # 禁用QOS同一台机器可能会有端口冲突现象
    qos-enable: false
    qos-accept-foreign-ip: false
  scan:
  	# 扫描rpc接口定义包
    base-packages: org.example.demo.service
  protocol:
    name: dubbo
    port: 8888
  registry:
    protocol: dubbo
    address: nacos://127.0.0.1:8848
    # 设置超时时间
    timeout: 3000
    # 配置 namespace
    parameters:
      namespace: 88b66463-1685-40b3-ba9c-7b25e526dcfb
     # 服务分组
    group: demo

mybatis-plus:
  mapper-locations: classpath:/mapper
	public void test() {
        try {
			String msg = demoService.test();
			log.info("rpc 调用获取到的数据为:{}", msg)
        } catch (RpcException e) {
            log.error("rpc 调用数据失败,错误信息为:", e);
        }
        return null;
    }

}

没有啥特殊要求,至此配置完成,可以愉快的玩耍了

Duplicate class org/apache/dubbo/remoting/exchange/Exchangers.class in 2 jar Duplicate class org/apache/dubbo/common/Version.class in 2 jar

由于最近很火的一个日志(log4j和log4j2)致命漏洞,需要将生产项目中log4j相关漏洞进行修复,本来在最初知道 log4j2 的漏洞后还暗自笑过,因为受这个漏洞影响的项目中是使用了log4j2相关的jar,比如常见的在项目中应用了 spring-boot-starter-log4j2 相关的依赖,但是我的项目中没有使用到log4j2,所以暗自庆幸了一下。因为比较旧的项目采用的spring-mvc 4.2.8,日志组件采用slf4j+log4j,spring-boot项目则是采用了官方的日志组件库 logback。但是紧跟着log4j2 漏洞出现后没过多久,log4j也暴雷了,所以得升级改造。。。

logback 漏洞: https://mp.weixin.qq.com/s/y10RXst0gRNZzmLyRt0GYA

进入主题,首先spring-boot 2.3.6 使用的 logback是1.2.3,需要升级到最新稳定版本 1.2.9
查看spring-boot-dependencies里面规定当前依赖的版本 用的 key。
在当前项目里面重写配置,如下面的代码,则可以替代默认的版本号。

	
        1.2.9
    

替换完之后发现项目中还有log4j的包,查看依赖后发现是 dubbo-registry-nacos 中使用到了log4j 1.2.6,在当前项目pom中进行移除

	
            org.apache.dubbo
            dubbo-registry-nacos
            ${dubbo.version}
            
                
                    log4j
                    log4j
                
            
        

启动项目,发现了错误信息
第一处错误

2021-12-31 16:39:24.633 ERROR 7440 --- [  restartedMain] org.apache.dubbo.common.Version          :  [DUBBO] Duplicate class org/apache/dubbo/common/Version.class in 2 jar [file:/F:/repository/org/apache/dubbo/dubbo/3.0.3/dubbo-3.0.3.jar!/org/apache/dubbo/common/Version.class, file:/F:/repository/org/apache/dubbo/dubbo-common/3.0.3/dubbo-common-3.0.3.jar!/org/apache/dubbo/common/Version.class], dubbo version: 3.0.3, current host: 192.168.28.1
2021-12-31 16:39:24.638  INFO 7440 --- [  restartedMain] d.s.b.c.e.WelcomeLogoApplicationListener : 

第二处错误

2021-12-31 16:39:32.886  WARN 7440 --- [  restartedMain] o.a.d.r.c.r.mesh.route.MeshRuleManager   :  [DUBBO] Doesn't support Configuration!, dubbo version: 3.0.3, current host: 192.168.28.1
2021-12-31 16:39:32.897 ERROR 7440 --- [  restartedMain] org.apache.dubbo.common.Version          :  [DUBBO] Duplicate class org/apache/dubbo/remoting/exchange/Exchangers.class in 2 jar [file:/F:/repository/org/apache/dubbo/dubbo/3.0.3/dubbo-3.0.3.jar!/org/apache/dubbo/remoting/exchange/Exchangers.class, file:/F:/repository/org/apache/dubbo/dubbo-remoting-api/3.0.3/dubbo-remoting-api-3.0.3.jar!/org/apache/dubbo/remoting/exchange/Exchangers.class], dubbo version: 3.0.3, current host: 192.168.28.1
2021-12-31 16:39:32.908 ERROR 7440 --- [  restartedMain] org.apache.dubbo.common.Version          :  [DUBBO] Duplicate class org/apache/dubbo/remoting/Transporters.class in 2 jar [file:/F:/repository/org/apache/dubbo/dubbo/3.0.3/dubbo-3.0.3.jar!/org/apache/dubbo/remoting/Transporters.class, file:/F:/repository/org/apache/dubbo/dubbo-remoting-api/3.0.3/dubbo-remoting-api-3.0.3.jar!/org/apache/dubbo/remoting/Transporters.class], dubbo version: 3.0.3, current host: 192.168.28.1
2021-12-31 16:39:32.908 ERROR 7440 --- [  restartedMain] org.apache.dubbo.common.Version          :  [DUBBO] Duplicate class org/apache/dubbo/remoting/RemotingException.class in 2 jar [file:/F:/repository/org/apache/dubbo/dubbo-remoting-api/3.0.3/dubbo-remoting-api-3.0.3.jar!/org/apache/dubbo/remoting/RemotingException.class, file:/F:/repository/org/apache/dubbo/dubbo/3.0.3/dubbo-3.0.3.jar!/org/apache/dubbo/remoting/RemotingException.class], dubbo version: 3.0.3, current host: 192.168.28.1

解决方法:
引入dubbo相关的依赖时,会有依赖传递,必须要exclude相关冲突的资源
参考:https://github.com/apache/dubbo-spring-boot-project/issues/227

		
            org.apache.dubbo
            dubbo-registry-nacos
            ${dubbo.version}
            
                
                    org.apache.dubbo
                    dubbo-common
                
                
                    org.apache.dubbo
                    dubbo-remoting-api
                
                
                    log4j
                    log4j
                
            
        
[dubbo] the metadata report was not initialized.

去掉log4j 导致 dubbo 启动错误

2021-12-31 16:39:33.247  WARN 7440 --- [  restartedMain] o.a.d.r.client.ServiceDiscoveryRegistry  :  [DUBBO] Cannot find app mapping for service tm.ucp.service.MeetingRecordingService, will not migrate., dubbo version: 3.0.3, current host: 192.168.28.1

java.lang.IllegalStateException: the metadata report was not initialized.
	at org.apache.dubbo.metadata.report.metadataReportInstance.checkInit(metadataReportInstance.java:88) ~[dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.metadata.report.metadataReportInstance.getmetadataReport(metadataReportInstance.java:77) ~[dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.metadata.metadataServiceNameMapping.getAndListen(metadataServiceNameMapping.java:107) ~[dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.metadata.AbstractServiceNameMapping.getAndListenServices(AbstractServiceNameMapping.java:101) ~[dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.doSubscribe(ServiceDiscoveryRegistry.java:215) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribe(ServiceDiscoveryRegistry.java:204) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.ListenerRegistryWrapper.subscribe(ListenerRegistryWrapper.java:109) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.DynamicDirectory.subscribe(DynamicDirectory.java:160) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.subscribe(ServiceDiscoveryRegistryDirectory.java:104) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.RegistryProtocol.doCreateInvoker(RegistryProtocol.java:557) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.InterfaceCompatibleRegistryProtocol.getServiceDiscoveryInvoker(InterfaceCompatibleRegistryProtocol.java:65) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationInvoker.refreshServiceDiscoveryInvoker(MigrationInvoker.java:424) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationInvoker.migrateToApplicationFirstInvoker(MigrationInvoker.java:240) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.refreshInvoker(MigrationRuleHandler.java:72) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.doMigrate(MigrationRuleHandler.java:56) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationRuleListener.onRefer(MigrationRuleListener.java:233) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.RegistryProtocol.interceptInvoker(RegistryProtocol.java:526) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:495) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:480) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:83) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:74) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:71) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.refer(ProtocolSerializationWrapper.java:52) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.ReferenceConfig.createInvokerForRemote(ReferenceConfig.java:469) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:380) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:267) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:204) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.spring.ReferenceBean.getCallProxy(ReferenceBean.java:348) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.spring.ReferenceBean.access0(ReferenceBean.java:98) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.spring.ReferenceBean$DubboReferenceLazyInitTargetSource.createObject(ReferenceBean.java:355) [dubbo-3.0.3.jar:3.0.3]
	at org.springframework.aop.target.AbstractLazyCreationTargetSource.getTarget(AbstractLazyCreationTargetSource.java:88) [spring-aop-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192) [spring-aop-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at com.sun.proxy.$Proxy142.listByUntreated(Unknown Source) [na:na]
	at tm.mye.mobile.rpc.server.GroupMeetingServiceImpl.getMeetingRecordingByUntreated(GroupMeetingServiceImpl.java:192) [classes/:na]
	at tm.mye.mobile.uap.server.TaskService.scheduleTask(TaskService.java:41) [classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$Lifecyclemetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:415) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1786) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean
dubbo:
  registry:
    address: nacos://127.0.0.1:8848
  # 配置dubbo 元数据
  metadata-report:
    address: nacos://127.0.0.1:8848
    group: demo
(AbstractBeanFactory.java:324) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeanByName(AbstractAutowireCapableBeanFactory.java:453) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:527) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:497) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:650) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.annotation.Injectionmetadata$InjectedElement.inject(Injectionmetadata.java:229) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.annotation.Injectionmetadata.inject(Injectionmetadata.java:119) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:318) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[+++](AbstractBeanFactory.java:324) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeanByName(AbstractAutowireCapableBeanFactory.java:453) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:527) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:497) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:650) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.annotation.Injectionmetadata$InjectedElement.inject(Injectionmetadata.java:229) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.annotation.Injectionmetadata.inject(Injectionmetadata.java:119) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:318) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[+++](AbstractBeanFactory.java:324) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at tm.mye.mobile.MobileApiApplication.main(MobileApiApplication.java:20) ~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.3.6.RELEASE.jar:2.3.6.RELEASE]

解决metadata report 初始化错误:
修改项目 application.yml

[+++]

元数据中心用于存储一些服务提供者、消费者的信息,比如dubbo版本、服务接口的信息(包括方法名、形参表、返回值类型)等等。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 54, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

Dubbo 3.0.3 + Nacos 2.0.3 + Spring Boot 2.3.6.RELEASE 整合及使用时遇到的问题

Dubbo 3.0.3 + Nacos 2.0.3 + spring boot 2.3.6.RELEASE 整合中遇到的问题

Dubbo 3.0.3 + Nacos 2.0.3 + spring boot 2.3.6.RELEASE 整合

由于公司的一些老项目使用的rpc(是由HTTPClient封装的一个调用工具包),考虑到性能低,维护起来又极其难受。在众多rpc框架中对比发现,加上dubbo又推出了3.0版本,再加上目前各大企业都是采用dubbo作为rpc框架。故推翻现有的rpc,采用dubbo 3.0.3 来替换项目中的rpc框架,阅读各大网站、论坛,帖子发现dubbo 2.x版大多数使用的还是zookeeper作为rpc的注册中心,由于之前学习过spring cloud H版后发现 nacos 做为服务注册中心也是一个很不错的选择,所以此次升级也是采用了nacos 2.0

项目框架搭建 服务提供者

pom.xml



    4.0.0

    org.example
    demo-provider
    1.0.0-SNAPSHOT

    
        org.springframework.boot
        spring-boot-dependencies
        2.3.6.RELEASE
    

    
        1.8
        UTF-8
        UTF-8
        2.3.6.RELEASE
        3.4.1
        1.1.21
        5.1.47
        3.0.3
        1.2.9
    

    

        
        
            org.example
            demo-interface
            1.0.0-SNAPSHOT
        

        
        
            org.springframework.boot
            spring-boot-starter-web
        
        
            org.springframework.boot
            spring-boot-starter-actuator
        
        
            org.springframework.boot
            spring-boot-starter-validation
        
        
            org.springframework.boot
            spring-boot-configuration-processor
        

        
        
            org.apache.dubbo
            dubbo-spring-boot-starter
            ${dubbo.version}
        
        
        
            org.apache.dubbo
            dubbo-registry-nacos
            ${dubbo.version}
        

        
        
            mysql
            mysql-connector-java
        
        
        
            com.alibaba
            druid-spring-boot-starter
            ${druid-spring-boot.version}
        
        
        
            com.baomidou
            mybatis-plus-boot-starter
            ${mybatis-plus-spring-boot.version}
        

        
        
            org.springframework.boot
            spring-boot-devtools
            runtime
            true
        

    

    
        demo-provider
        
            
                org.apache.maven.plugins
                maven-compiler-plugin
                
                    ${java.version}
                    ${java.version}
                    ${project.build.sourceEncoding}
                
            
            
                org.springframework.boot
                spring-boot-maven-plugin
                
                    true
                    true
                    org.example.DemoApplication
                
                
                    
                        repackage
                        
                            repackage
                        
                    
                
            
        
    


application.yml

server:
  port: 8080

spring:
  application:
    name: dubbo-demo-provider
  jackson:
    time-zone: GMT+8
    date-format: yyyy-MM-dd HH:mm:ss
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/demo?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&autoReconnectForPools=true&useSSL=false
    username: root
    password: 123456
    druid:
      initialSize: 5
      minIdle: 5
      maxActive: 20
      # 配置获取连接等待超时的时间
      maxWait: 60000
      # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
      timeBetweenEvictionRunsMillis: 60000
      # 配置一个连接在池中最小生存的时间,单位是毫秒
      minEvictableIdleTimeMillis: 300000
      validationQuery: select 'x'
      testWhileIdle: true
      testOnBorrow: false
      testOnReturn: false
      # 打开PSCache,并且指定每个连接上PSCache的大小
      poolPreparedStatements: true
      maxPoolPreparedStatementPerConnectionSize: 20
      # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
      filters: stat,wall,slf4j
      # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
      connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000

dubbo:
  application:
    name: dubbo-demo-provider
    # 禁用QOS同一台机器可能会有端口冲突现象
    qos-enable: false
    qos-accept-foreign-ip: false
  scan:
  	# 扫描rpc接口定义包
    base-packages: org.example.demo.service
  protocol:
    name: dubbo
    port: 8888
  registry:
    protocol: dubbo
    address: nacos://127.0.0.1:8848
    # 设置超时时间
    timeout: 3000
    # 配置 namespace
    parameters:
      namespace: 88b66463-1685-40b3-ba9c-7b25e526dcfb
     # 服务分组
    group: demo

mybatis-plus:
  mapper-locations: classpath:/mapper
	public void test() {
        try {
			String msg = demoService.test();
			log.info("rpc 调用获取到的数据为:{}", msg)
        } catch (RpcException e) {
            log.error("rpc 调用数据失败,错误信息为:", e);
        }
        return null;
    }

}

没有啥特殊要求,至此配置完成,可以愉快的玩耍了

Duplicate class org/apache/dubbo/remoting/exchange/Exchangers.class in 2 jar Duplicate class org/apache/dubbo/common/Version.class in 2 jar

由于最近很火的一个日志(log4j和log4j2)致命漏洞,需要将生产项目中log4j相关漏洞进行修复,本来在最初知道 log4j2 的漏洞后还暗自笑过,因为受这个漏洞影响的项目中是使用了log4j2相关的jar,比如常见的在项目中应用了 spring-boot-starter-log4j2 相关的依赖,但是我的项目中没有使用到log4j2,所以暗自庆幸了一下。因为比较旧的项目采用的spring-mvc 4.2.8,日志组件采用slf4j+log4j,spring-boot项目则是采用了官方的日志组件库 logback。但是紧跟着log4j2 漏洞出现后没过多久,log4j也暴雷了,所以得升级改造。。。

logback 漏洞: https://mp.weixin.qq.com/s/y10RXst0gRNZzmLyRt0GYA

进入主题,首先spring-boot 2.3.6 使用的 logback是1.2.3,需要升级到最新稳定版本 1.2.9
查看spring-boot-dependencies里面规定当前依赖的版本 用的 key。
在当前项目里面重写配置,如下面的代码,则可以替代默认的版本号。

	
        1.2.9
    

替换完之后发现项目中还有log4j的包,查看依赖后发现是 dubbo-registry-nacos 中使用到了log4j 1.2.6,在当前项目pom中进行移除

	
            org.apache.dubbo
            dubbo-registry-nacos
            ${dubbo.version}
            
                
                    log4j
                    log4j
                
            
        

启动项目,发现了错误信息
第一处错误

2021-12-31 16:39:24.633 ERROR 7440 --- [  restartedMain] org.apache.dubbo.common.Version          :  [DUBBO] Duplicate class org/apache/dubbo/common/Version.class in 2 jar [file:/F:/repository/org/apache/dubbo/dubbo/3.0.3/dubbo-3.0.3.jar!/org/apache/dubbo/common/Version.class, file:/F:/repository/org/apache/dubbo/dubbo-common/3.0.3/dubbo-common-3.0.3.jar!/org/apache/dubbo/common/Version.class], dubbo version: 3.0.3, current host: 192.168.28.1
2021-12-31 16:39:24.638  INFO 7440 --- [  restartedMain] d.s.b.c.e.WelcomeLogoApplicationListener : 

第二处错误

2021-12-31 16:39:32.886  WARN 7440 --- [  restartedMain] o.a.d.r.c.r.mesh.route.MeshRuleManager   :  [DUBBO] Doesn't support Configuration!, dubbo version: 3.0.3, current host: 192.168.28.1
2021-12-31 16:39:32.897 ERROR 7440 --- [  restartedMain] org.apache.dubbo.common.Version          :  [DUBBO] Duplicate class org/apache/dubbo/remoting/exchange/Exchangers.class in 2 jar [file:/F:/repository/org/apache/dubbo/dubbo/3.0.3/dubbo-3.0.3.jar!/org/apache/dubbo/remoting/exchange/Exchangers.class, file:/F:/repository/org/apache/dubbo/dubbo-remoting-api/3.0.3/dubbo-remoting-api-3.0.3.jar!/org/apache/dubbo/remoting/exchange/Exchangers.class], dubbo version: 3.0.3, current host: 192.168.28.1
2021-12-31 16:39:32.908 ERROR 7440 --- [  restartedMain] org.apache.dubbo.common.Version          :  [DUBBO] Duplicate class org/apache/dubbo/remoting/Transporters.class in 2 jar [file:/F:/repository/org/apache/dubbo/dubbo/3.0.3/dubbo-3.0.3.jar!/org/apache/dubbo/remoting/Transporters.class, file:/F:/repository/org/apache/dubbo/dubbo-remoting-api/3.0.3/dubbo-remoting-api-3.0.3.jar!/org/apache/dubbo/remoting/Transporters.class], dubbo version: 3.0.3, current host: 192.168.28.1
2021-12-31 16:39:32.908 ERROR 7440 --- [  restartedMain] org.apache.dubbo.common.Version          :  [DUBBO] Duplicate class org/apache/dubbo/remoting/RemotingException.class in 2 jar [file:/F:/repository/org/apache/dubbo/dubbo-remoting-api/3.0.3/dubbo-remoting-api-3.0.3.jar!/org/apache/dubbo/remoting/RemotingException.class, file:/F:/repository/org/apache/dubbo/dubbo/3.0.3/dubbo-3.0.3.jar!/org/apache/dubbo/remoting/RemotingException.class], dubbo version: 3.0.3, current host: 192.168.28.1

解决方法:
引入dubbo相关的依赖时,会有依赖传递,必须要exclude相关冲突的资源
参考:https://github.com/apache/dubbo-spring-boot-project/issues/227

		
            org.apache.dubbo
            dubbo-registry-nacos
            ${dubbo.version}
            
                
                    org.apache.dubbo
                    dubbo-common
                
                
                    org.apache.dubbo
                    dubbo-remoting-api
                
                
                    log4j
                    log4j
                
            
        
[dubbo] the metadata report was not initialized.

去掉log4j 导致 dubbo 启动错误

2021-12-31 16:39:33.247  WARN 7440 --- [  restartedMain] o.a.d.r.client.ServiceDiscoveryRegistry  :  [DUBBO] Cannot find app mapping for service tm.ucp.service.MeetingRecordingService, will not migrate., dubbo version: 3.0.3, current host: 192.168.28.1

java.lang.IllegalStateException: the metadata report was not initialized.
	at org.apache.dubbo.metadata.report.metadataReportInstance.checkInit(metadataReportInstance.java:88) ~[dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.metadata.report.metadataReportInstance.getmetadataReport(metadataReportInstance.java:77) ~[dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.metadata.metadataServiceNameMapping.getAndListen(metadataServiceNameMapping.java:107) ~[dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.metadata.AbstractServiceNameMapping.getAndListenServices(AbstractServiceNameMapping.java:101) ~[dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.doSubscribe(ServiceDiscoveryRegistry.java:215) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribe(ServiceDiscoveryRegistry.java:204) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.ListenerRegistryWrapper.subscribe(ListenerRegistryWrapper.java:109) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.DynamicDirectory.subscribe(DynamicDirectory.java:160) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.subscribe(ServiceDiscoveryRegistryDirectory.java:104) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.RegistryProtocol.doCreateInvoker(RegistryProtocol.java:557) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.InterfaceCompatibleRegistryProtocol.getServiceDiscoveryInvoker(InterfaceCompatibleRegistryProtocol.java:65) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationInvoker.refreshServiceDiscoveryInvoker(MigrationInvoker.java:424) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationInvoker.migrateToApplicationFirstInvoker(MigrationInvoker.java:240) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.refreshInvoker(MigrationRuleHandler.java:72) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.doMigrate(MigrationRuleHandler.java:56) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationRuleListener.onRefer(MigrationRuleListener.java:233) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.RegistryProtocol.interceptInvoker(RegistryProtocol.java:526) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:495) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:480) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:83) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:74) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:71) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.refer(ProtocolSerializationWrapper.java:52) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.ReferenceConfig.createInvokerForRemote(ReferenceConfig.java:469) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:380) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:267) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:204) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.spring.ReferenceBean.getCallProxy(ReferenceBean.java:348) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.spring.ReferenceBean.access0(ReferenceBean.java:98) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.spring.ReferenceBean$DubboReferenceLazyInitTargetSource.createObject(ReferenceBean.java:355) [dubbo-3.0.3.jar:3.0.3]
	at org.springframework.aop.target.AbstractLazyCreationTargetSource.getTarget(AbstractLazyCreationTargetSource.java:88) [spring-aop-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192) [spring-aop-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at com.sun.proxy.$Proxy142.listByUntreated(Unknown Source) [na:na]
	at tm.mye.mobile.rpc.server.GroupMeetingServiceImpl.getMeetingRecordingByUntreated(GroupMeetingServiceImpl.java:192) [classes/:na]
	at tm.mye.mobile.uap.server.TaskService.scheduleTask(TaskService.java:41) [classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$Lifecyclemetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:415) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1786) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean
dubbo:
  registry:
    address: nacos://127.0.0.1:8848
  # 配置dubbo 元数据
  metadata-report:
    address: nacos://127.0.0.1:8848
    group: demo
(AbstractBeanFactory.java:324) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeanByName(AbstractAutowireCapableBeanFactory.java:453) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:527) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:497) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:650) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.annotation.Injectionmetadata$InjectedElement.inject(Injectionmetadata.java:229) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.annotation.Injectionmetadata.inject(Injectionmetadata.java:119) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:318) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean(AbstractBeanFactory.java:324) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeanByName(AbstractAutowireCapableBeanFactory.java:453) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:527) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:497) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:650) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.annotation.Injectionmetadata$InjectedElement.inject(Injectionmetadata.java:229) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.annotation.Injectionmetadata.inject(Injectionmetadata.java:119) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:318) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[+++](AbstractBeanFactory.java:324) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at tm.mye.mobile.MobileApiApplication.main(MobileApiApplication.java:20) ~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.3.6.RELEASE.jar:2.3.6.RELEASE]

解决metadata report 初始化错误:
修改项目 application.yml

[+++]

元数据中心用于存储一些服务提供者、消费者的信息,比如dubbo版本、服务接口的信息(包括方法名、形参表、返回值类型)等等。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 55, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

Dubbo 3.0.3 + Nacos 2.0.3 + Spring Boot 2.3.6.RELEASE 整合及使用时遇到的问题

Dubbo 3.0.3 + Nacos 2.0.3 + spring boot 2.3.6.RELEASE 整合中遇到的问题

Dubbo 3.0.3 + Nacos 2.0.3 + spring boot 2.3.6.RELEASE 整合

由于公司的一些老项目使用的rpc(是由HTTPClient封装的一个调用工具包),考虑到性能低,维护起来又极其难受。在众多rpc框架中对比发现,加上dubbo又推出了3.0版本,再加上目前各大企业都是采用dubbo作为rpc框架。故推翻现有的rpc,采用dubbo 3.0.3 来替换项目中的rpc框架,阅读各大网站、论坛,帖子发现dubbo 2.x版大多数使用的还是zookeeper作为rpc的注册中心,由于之前学习过spring cloud H版后发现 nacos 做为服务注册中心也是一个很不错的选择,所以此次升级也是采用了nacos 2.0

项目框架搭建 服务提供者

pom.xml



    4.0.0

    org.example
    demo-provider
    1.0.0-SNAPSHOT

    
        org.springframework.boot
        spring-boot-dependencies
        2.3.6.RELEASE
    

    
        1.8
        UTF-8
        UTF-8
        2.3.6.RELEASE
        3.4.1
        1.1.21
        5.1.47
        3.0.3
        1.2.9
    

    

        
        
            org.example
            demo-interface
            1.0.0-SNAPSHOT
        

        
        
            org.springframework.boot
            spring-boot-starter-web
        
        
            org.springframework.boot
            spring-boot-starter-actuator
        
        
            org.springframework.boot
            spring-boot-starter-validation
        
        
            org.springframework.boot
            spring-boot-configuration-processor
        

        
        
            org.apache.dubbo
            dubbo-spring-boot-starter
            ${dubbo.version}
        
        
        
            org.apache.dubbo
            dubbo-registry-nacos
            ${dubbo.version}
        

        
        
            mysql
            mysql-connector-java
        
        
        
            com.alibaba
            druid-spring-boot-starter
            ${druid-spring-boot.version}
        
        
        
            com.baomidou
            mybatis-plus-boot-starter
            ${mybatis-plus-spring-boot.version}
        

        
        
            org.springframework.boot
            spring-boot-devtools
            runtime
            true
        

    

    
        demo-provider
        
            
                org.apache.maven.plugins
                maven-compiler-plugin
                
                    ${java.version}
                    ${java.version}
                    ${project.build.sourceEncoding}
                
            
            
                org.springframework.boot
                spring-boot-maven-plugin
                
                    true
                    true
                    org.example.DemoApplication
                
                
                    
                        repackage
                        
                            repackage
                        
                    
                
            
        
    


application.yml

server:
  port: 8080

spring:
  application:
    name: dubbo-demo-provider
  jackson:
    time-zone: GMT+8
    date-format: yyyy-MM-dd HH:mm:ss
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/demo?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&autoReconnectForPools=true&useSSL=false
    username: root
    password: 123456
    druid:
      initialSize: 5
      minIdle: 5
      maxActive: 20
      # 配置获取连接等待超时的时间
      maxWait: 60000
      # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
      timeBetweenEvictionRunsMillis: 60000
      # 配置一个连接在池中最小生存的时间,单位是毫秒
      minEvictableIdleTimeMillis: 300000
      validationQuery: select 'x'
      testWhileIdle: true
      testOnBorrow: false
      testOnReturn: false
      # 打开PSCache,并且指定每个连接上PSCache的大小
      poolPreparedStatements: true
      maxPoolPreparedStatementPerConnectionSize: 20
      # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
      filters: stat,wall,slf4j
      # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
      connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000

dubbo:
  application:
    name: dubbo-demo-provider
    # 禁用QOS同一台机器可能会有端口冲突现象
    qos-enable: false
    qos-accept-foreign-ip: false
  scan:
  	# 扫描rpc接口定义包
    base-packages: org.example.demo.service
  protocol:
    name: dubbo
    port: 8888
  registry:
    protocol: dubbo
    address: nacos://127.0.0.1:8848
    # 设置超时时间
    timeout: 3000
    # 配置 namespace
    parameters:
      namespace: 88b66463-1685-40b3-ba9c-7b25e526dcfb
     # 服务分组
    group: demo

mybatis-plus:
  mapper-locations: classpath:/mapper
	public void test() {
        try {
			String msg = demoService.test();
			log.info("rpc 调用获取到的数据为:{}", msg)
        } catch (RpcException e) {
            log.error("rpc 调用数据失败,错误信息为:", e);
        }
        return null;
    }

}

没有啥特殊要求,至此配置完成,可以愉快的玩耍了

Duplicate class org/apache/dubbo/remoting/exchange/Exchangers.class in 2 jar Duplicate class org/apache/dubbo/common/Version.class in 2 jar

由于最近很火的一个日志(log4j和log4j2)致命漏洞,需要将生产项目中log4j相关漏洞进行修复,本来在最初知道 log4j2 的漏洞后还暗自笑过,因为受这个漏洞影响的项目中是使用了log4j2相关的jar,比如常见的在项目中应用了 spring-boot-starter-log4j2 相关的依赖,但是我的项目中没有使用到log4j2,所以暗自庆幸了一下。因为比较旧的项目采用的spring-mvc 4.2.8,日志组件采用slf4j+log4j,spring-boot项目则是采用了官方的日志组件库 logback。但是紧跟着log4j2 漏洞出现后没过多久,log4j也暴雷了,所以得升级改造。。。

logback 漏洞: https://mp.weixin.qq.com/s/y10RXst0gRNZzmLyRt0GYA

进入主题,首先spring-boot 2.3.6 使用的 logback是1.2.3,需要升级到最新稳定版本 1.2.9
查看spring-boot-dependencies里面规定当前依赖的版本 用的 key。
在当前项目里面重写配置,如下面的代码,则可以替代默认的版本号。

	
        1.2.9
    

替换完之后发现项目中还有log4j的包,查看依赖后发现是 dubbo-registry-nacos 中使用到了log4j 1.2.6,在当前项目pom中进行移除

	
            org.apache.dubbo
            dubbo-registry-nacos
            ${dubbo.version}
            
                
                    log4j
                    log4j
                
            
        

启动项目,发现了错误信息
第一处错误

2021-12-31 16:39:24.633 ERROR 7440 --- [  restartedMain] org.apache.dubbo.common.Version          :  [DUBBO] Duplicate class org/apache/dubbo/common/Version.class in 2 jar [file:/F:/repository/org/apache/dubbo/dubbo/3.0.3/dubbo-3.0.3.jar!/org/apache/dubbo/common/Version.class, file:/F:/repository/org/apache/dubbo/dubbo-common/3.0.3/dubbo-common-3.0.3.jar!/org/apache/dubbo/common/Version.class], dubbo version: 3.0.3, current host: 192.168.28.1
2021-12-31 16:39:24.638  INFO 7440 --- [  restartedMain] d.s.b.c.e.WelcomeLogoApplicationListener : 

第二处错误

2021-12-31 16:39:32.886  WARN 7440 --- [  restartedMain] o.a.d.r.c.r.mesh.route.MeshRuleManager   :  [DUBBO] Doesn't support Configuration!, dubbo version: 3.0.3, current host: 192.168.28.1
2021-12-31 16:39:32.897 ERROR 7440 --- [  restartedMain] org.apache.dubbo.common.Version          :  [DUBBO] Duplicate class org/apache/dubbo/remoting/exchange/Exchangers.class in 2 jar [file:/F:/repository/org/apache/dubbo/dubbo/3.0.3/dubbo-3.0.3.jar!/org/apache/dubbo/remoting/exchange/Exchangers.class, file:/F:/repository/org/apache/dubbo/dubbo-remoting-api/3.0.3/dubbo-remoting-api-3.0.3.jar!/org/apache/dubbo/remoting/exchange/Exchangers.class], dubbo version: 3.0.3, current host: 192.168.28.1
2021-12-31 16:39:32.908 ERROR 7440 --- [  restartedMain] org.apache.dubbo.common.Version          :  [DUBBO] Duplicate class org/apache/dubbo/remoting/Transporters.class in 2 jar [file:/F:/repository/org/apache/dubbo/dubbo/3.0.3/dubbo-3.0.3.jar!/org/apache/dubbo/remoting/Transporters.class, file:/F:/repository/org/apache/dubbo/dubbo-remoting-api/3.0.3/dubbo-remoting-api-3.0.3.jar!/org/apache/dubbo/remoting/Transporters.class], dubbo version: 3.0.3, current host: 192.168.28.1
2021-12-31 16:39:32.908 ERROR 7440 --- [  restartedMain] org.apache.dubbo.common.Version          :  [DUBBO] Duplicate class org/apache/dubbo/remoting/RemotingException.class in 2 jar [file:/F:/repository/org/apache/dubbo/dubbo-remoting-api/3.0.3/dubbo-remoting-api-3.0.3.jar!/org/apache/dubbo/remoting/RemotingException.class, file:/F:/repository/org/apache/dubbo/dubbo/3.0.3/dubbo-3.0.3.jar!/org/apache/dubbo/remoting/RemotingException.class], dubbo version: 3.0.3, current host: 192.168.28.1

解决方法:
引入dubbo相关的依赖时,会有依赖传递,必须要exclude相关冲突的资源
参考:https://github.com/apache/dubbo-spring-boot-project/issues/227

		
            org.apache.dubbo
            dubbo-registry-nacos
            ${dubbo.version}
            
                
                    org.apache.dubbo
                    dubbo-common
                
                
                    org.apache.dubbo
                    dubbo-remoting-api
                
                
                    log4j
                    log4j
                
            
        
[dubbo] the metadata report was not initialized.

去掉log4j 导致 dubbo 启动错误

2021-12-31 16:39:33.247  WARN 7440 --- [  restartedMain] o.a.d.r.client.ServiceDiscoveryRegistry  :  [DUBBO] Cannot find app mapping for service tm.ucp.service.MeetingRecordingService, will not migrate., dubbo version: 3.0.3, current host: 192.168.28.1

java.lang.IllegalStateException: the metadata report was not initialized.
	at org.apache.dubbo.metadata.report.metadataReportInstance.checkInit(metadataReportInstance.java:88) ~[dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.metadata.report.metadataReportInstance.getmetadataReport(metadataReportInstance.java:77) ~[dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.metadata.metadataServiceNameMapping.getAndListen(metadataServiceNameMapping.java:107) ~[dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.metadata.AbstractServiceNameMapping.getAndListenServices(AbstractServiceNameMapping.java:101) ~[dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.doSubscribe(ServiceDiscoveryRegistry.java:215) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribe(ServiceDiscoveryRegistry.java:204) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.ListenerRegistryWrapper.subscribe(ListenerRegistryWrapper.java:109) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.DynamicDirectory.subscribe(DynamicDirectory.java:160) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.subscribe(ServiceDiscoveryRegistryDirectory.java:104) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.RegistryProtocol.doCreateInvoker(RegistryProtocol.java:557) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.InterfaceCompatibleRegistryProtocol.getServiceDiscoveryInvoker(InterfaceCompatibleRegistryProtocol.java:65) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationInvoker.refreshServiceDiscoveryInvoker(MigrationInvoker.java:424) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationInvoker.migrateToApplicationFirstInvoker(MigrationInvoker.java:240) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.refreshInvoker(MigrationRuleHandler.java:72) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.doMigrate(MigrationRuleHandler.java:56) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationRuleListener.onRefer(MigrationRuleListener.java:233) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.RegistryProtocol.interceptInvoker(RegistryProtocol.java:526) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:495) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:480) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:83) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:74) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:71) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.refer(ProtocolSerializationWrapper.java:52) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.ReferenceConfig.createInvokerForRemote(ReferenceConfig.java:469) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:380) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:267) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:204) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.spring.ReferenceBean.getCallProxy(ReferenceBean.java:348) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.spring.ReferenceBean.access0(ReferenceBean.java:98) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.spring.ReferenceBean$DubboReferenceLazyInitTargetSource.createObject(ReferenceBean.java:355) [dubbo-3.0.3.jar:3.0.3]
	at org.springframework.aop.target.AbstractLazyCreationTargetSource.getTarget(AbstractLazyCreationTargetSource.java:88) [spring-aop-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192) [spring-aop-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at com.sun.proxy.$Proxy142.listByUntreated(Unknown Source) [na:na]
	at tm.mye.mobile.rpc.server.GroupMeetingServiceImpl.getMeetingRecordingByUntreated(GroupMeetingServiceImpl.java:192) [classes/:na]
	at tm.mye.mobile.uap.server.TaskService.scheduleTask(TaskService.java:41) [classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$Lifecyclemetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:415) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1786) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean
dubbo:
  registry:
    address: nacos://127.0.0.1:8848
  # 配置dubbo 元数据
  metadata-report:
    address: nacos://127.0.0.1:8848
    group: demo
(AbstractBeanFactory.java:324) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeanByName(AbstractAutowireCapableBeanFactory.java:453) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:527) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:497) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:650) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.annotation.Injectionmetadata$InjectedElement.inject(Injectionmetadata.java:229) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.annotation.Injectionmetadata.inject(Injectionmetadata.java:119) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:318) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean(AbstractBeanFactory.java:324) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeanByName(AbstractAutowireCapableBeanFactory.java:453) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:527) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:497) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:650) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.annotation.Injectionmetadata$InjectedElement.inject(Injectionmetadata.java:229) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.annotation.Injectionmetadata.inject(Injectionmetadata.java:119) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:318) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean(AbstractBeanFactory.java:324) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at tm.mye.mobile.MobileApiApplication.main(MobileApiApplication.java:20) ~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.3.6.RELEASE.jar:2.3.6.RELEASE]

解决metadata report 初始化错误:
修改项目 application.yml

[+++]

元数据中心用于存储一些服务提供者、消费者的信息,比如dubbo版本、服务接口的信息(包括方法名、形参表、返回值类型)等等。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Dubbo 3.0.3 + Nacos 2.0.3 + Spring Boot 2.3.6.RELEASE 整合及使用时遇到的问题_随笔_内存溢出

Dubbo 3.0.3 + Nacos 2.0.3 + Spring Boot 2.3.6.RELEASE 整合及使用时遇到的问题

Dubbo 3.0.3 + Nacos 2.0.3 + Spring Boot 2.3.6.RELEASE 整合及使用时遇到的问题,第1张

Dubbo 3.0.3 + Nacos 2.0.3 + Spring Boot 2.3.6.RELEASE 整合及使用时遇到的问题

Dubbo 3.0.3 + Nacos 2.0.3 + spring boot 2.3.6.RELEASE 整合中遇到的问题
  • Dubbo 3.0.3 + Nacos 2.0.3 + spring boot 2.3.6.RELEASE 整合
    • 项目框架搭建
      • 服务提供者
      • 服务消费者
    • Duplicate class org/apache/dubbo/remoting/exchange/Exchangers.class in 2 jar
    • Duplicate class org/apache/dubbo/common/Version.class in 2 jar
    • [dubbo] the metadata report was not initialized.

Dubbo 3.0.3 + Nacos 2.0.3 + spring boot 2.3.6.RELEASE 整合

由于公司的一些老项目使用的rpc(是由HTTPClient封装的一个调用工具包),考虑到性能低,维护起来又极其难受。在众多rpc框架中对比发现,加上dubbo又推出了3.0版本,再加上目前各大企业都是采用dubbo作为rpc框架。故推翻现有的rpc,采用dubbo 3.0.3 来替换项目中的rpc框架,阅读各大网站、论坛,帖子发现dubbo 2.x版大多数使用的还是zookeeper作为rpc的注册中心,由于之前学习过spring cloud H版后发现 nacos 做为服务注册中心也是一个很不错的选择,所以此次升级也是采用了nacos 2.0

项目框架搭建 服务提供者

pom.xml



    4.0.0

    org.example
    demo-provider
    1.0.0-SNAPSHOT

    
        org.springframework.boot
        spring-boot-dependencies
        2.3.6.RELEASE
    

    
        1.8
        UTF-8
        UTF-8
        2.3.6.RELEASE
        3.4.1
        1.1.21
        5.1.47
        3.0.3
        1.2.9
    

    

        
        
            org.example
            demo-interface
            1.0.0-SNAPSHOT
        

        
        
            org.springframework.boot
            spring-boot-starter-web
        
        
            org.springframework.boot
            spring-boot-starter-actuator
        
        
            org.springframework.boot
            spring-boot-starter-validation
        
        
            org.springframework.boot
            spring-boot-configuration-processor
        

        
        
            org.apache.dubbo
            dubbo-spring-boot-starter
            ${dubbo.version}
        
        
        
            org.apache.dubbo
            dubbo-registry-nacos
            ${dubbo.version}
        

        
        
            mysql
            mysql-connector-java
        
        
        
            com.alibaba
            druid-spring-boot-starter
            ${druid-spring-boot.version}
        
        
        
            com.baomidou
            mybatis-plus-boot-starter
            ${mybatis-plus-spring-boot.version}
        

        
        
            org.springframework.boot
            spring-boot-devtools
            runtime
            true
        

    

    
        demo-provider
        
            
                org.apache.maven.plugins
                maven-compiler-plugin
                
                    ${java.version}
                    ${java.version}
                    ${project.build.sourceEncoding}
                
            
            
                org.springframework.boot
                spring-boot-maven-plugin
                
                    true
                    true
                    org.example.DemoApplication
                
                
                    
                        repackage
                        
                            repackage
                        
                    
                
            
        
    


application.yml

server:
  port: 8080

spring:
  application:
    name: dubbo-demo-provider
  jackson:
    time-zone: GMT+8
    date-format: yyyy-MM-dd HH:mm:ss
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/demo?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&autoReconnectForPools=true&useSSL=false
    username: root
    password: 123456
    druid:
      initialSize: 5
      minIdle: 5
      maxActive: 20
      # 配置获取连接等待超时的时间
      maxWait: 60000
      # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
      timeBetweenEvictionRunsMillis: 60000
      # 配置一个连接在池中最小生存的时间,单位是毫秒
      minEvictableIdleTimeMillis: 300000
      validationQuery: select 'x'
      testWhileIdle: true
      testOnBorrow: false
      testOnReturn: false
      # 打开PSCache,并且指定每个连接上PSCache的大小
      poolPreparedStatements: true
      maxPoolPreparedStatementPerConnectionSize: 20
      # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
      filters: stat,wall,slf4j
      # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
      connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000

dubbo:
  application:
    name: dubbo-demo-provider
    # 禁用QOS同一台机器可能会有端口冲突现象
    qos-enable: false
    qos-accept-foreign-ip: false
  scan:
  	# 扫描rpc接口定义包
    base-packages: org.example.demo.service
  protocol:
    name: dubbo
    port: 8888
  registry:
    protocol: dubbo
    address: nacos://127.0.0.1:8848
    # 设置超时时间
    timeout: 3000
    # 配置 namespace
    parameters:
      namespace: 88b66463-1685-40b3-ba9c-7b25e526dcfb
     # 服务分组
    group: demo

mybatis-plus:
  mapper-locations: classpath:/mapper
	public void test() {
        try {
			String msg = demoService.test();
			log.info("rpc 调用获取到的数据为:{}", msg)
        } catch (RpcException e) {
            log.error("rpc 调用数据失败,错误信息为:", e);
        }
        return null;
    }

}

没有啥特殊要求,至此配置完成,可以愉快的玩耍了

Duplicate class org/apache/dubbo/remoting/exchange/Exchangers.class in 2 jar Duplicate class org/apache/dubbo/common/Version.class in 2 jar

由于最近很火的一个日志(log4j和log4j2)致命漏洞,需要将生产项目中log4j相关漏洞进行修复,本来在最初知道 log4j2 的漏洞后还暗自笑过,因为受这个漏洞影响的项目中是使用了log4j2相关的jar,比如常见的在项目中应用了 spring-boot-starter-log4j2 相关的依赖,但是我的项目中没有使用到log4j2,所以暗自庆幸了一下。因为比较旧的项目采用的spring-mvc 4.2.8,日志组件采用slf4j+log4j,spring-boot项目则是采用了官方的日志组件库 logback。但是紧跟着log4j2 漏洞出现后没过多久,log4j也暴雷了,所以得升级改造。。。

logback 漏洞: https://mp.weixin.qq.com/s/y10RXst0gRNZzmLyRt0GYA

进入主题,首先spring-boot 2.3.6 使用的 logback是1.2.3,需要升级到最新稳定版本 1.2.9
查看spring-boot-dependencies里面规定当前依赖的版本 用的 key。
在当前项目里面重写配置,如下面的代码,则可以替代默认的版本号。

	
        1.2.9
    

替换完之后发现项目中还有log4j的包,查看依赖后发现是 dubbo-registry-nacos 中使用到了log4j 1.2.6,在当前项目pom中进行移除

	
            org.apache.dubbo
            dubbo-registry-nacos
            ${dubbo.version}
            
                
                    log4j
                    log4j
                
            
        

启动项目,发现了错误信息
第一处错误

2021-12-31 16:39:24.633 ERROR 7440 --- [  restartedMain] org.apache.dubbo.common.Version          :  [DUBBO] Duplicate class org/apache/dubbo/common/Version.class in 2 jar [file:/F:/repository/org/apache/dubbo/dubbo/3.0.3/dubbo-3.0.3.jar!/org/apache/dubbo/common/Version.class, file:/F:/repository/org/apache/dubbo/dubbo-common/3.0.3/dubbo-common-3.0.3.jar!/org/apache/dubbo/common/Version.class], dubbo version: 3.0.3, current host: 192.168.28.1
2021-12-31 16:39:24.638  INFO 7440 --- [  restartedMain] d.s.b.c.e.WelcomeLogoApplicationListener : 

第二处错误

2021-12-31 16:39:32.886  WARN 7440 --- [  restartedMain] o.a.d.r.c.r.mesh.route.MeshRuleManager   :  [DUBBO] Doesn't support Configuration!, dubbo version: 3.0.3, current host: 192.168.28.1
2021-12-31 16:39:32.897 ERROR 7440 --- [  restartedMain] org.apache.dubbo.common.Version          :  [DUBBO] Duplicate class org/apache/dubbo/remoting/exchange/Exchangers.class in 2 jar [file:/F:/repository/org/apache/dubbo/dubbo/3.0.3/dubbo-3.0.3.jar!/org/apache/dubbo/remoting/exchange/Exchangers.class, file:/F:/repository/org/apache/dubbo/dubbo-remoting-api/3.0.3/dubbo-remoting-api-3.0.3.jar!/org/apache/dubbo/remoting/exchange/Exchangers.class], dubbo version: 3.0.3, current host: 192.168.28.1
2021-12-31 16:39:32.908 ERROR 7440 --- [  restartedMain] org.apache.dubbo.common.Version          :  [DUBBO] Duplicate class org/apache/dubbo/remoting/Transporters.class in 2 jar [file:/F:/repository/org/apache/dubbo/dubbo/3.0.3/dubbo-3.0.3.jar!/org/apache/dubbo/remoting/Transporters.class, file:/F:/repository/org/apache/dubbo/dubbo-remoting-api/3.0.3/dubbo-remoting-api-3.0.3.jar!/org/apache/dubbo/remoting/Transporters.class], dubbo version: 3.0.3, current host: 192.168.28.1
2021-12-31 16:39:32.908 ERROR 7440 --- [  restartedMain] org.apache.dubbo.common.Version          :  [DUBBO] Duplicate class org/apache/dubbo/remoting/RemotingException.class in 2 jar [file:/F:/repository/org/apache/dubbo/dubbo-remoting-api/3.0.3/dubbo-remoting-api-3.0.3.jar!/org/apache/dubbo/remoting/RemotingException.class, file:/F:/repository/org/apache/dubbo/dubbo/3.0.3/dubbo-3.0.3.jar!/org/apache/dubbo/remoting/RemotingException.class], dubbo version: 3.0.3, current host: 192.168.28.1

解决方法:
引入dubbo相关的依赖时,会有依赖传递,必须要exclude相关冲突的资源
参考:https://github.com/apache/dubbo-spring-boot-project/issues/227

		
            org.apache.dubbo
            dubbo-registry-nacos
            ${dubbo.version}
            
                
                    org.apache.dubbo
                    dubbo-common
                
                
                    org.apache.dubbo
                    dubbo-remoting-api
                
                
                    log4j
                    log4j
                
            
        
[dubbo] the metadata report was not initialized.

去掉log4j 导致 dubbo 启动错误

2021-12-31 16:39:33.247  WARN 7440 --- [  restartedMain] o.a.d.r.client.ServiceDiscoveryRegistry  :  [DUBBO] Cannot find app mapping for service tm.ucp.service.MeetingRecordingService, will not migrate., dubbo version: 3.0.3, current host: 192.168.28.1

java.lang.IllegalStateException: the metadata report was not initialized.
	at org.apache.dubbo.metadata.report.metadataReportInstance.checkInit(metadataReportInstance.java:88) ~[dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.metadata.report.metadataReportInstance.getmetadataReport(metadataReportInstance.java:77) ~[dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.metadata.metadataServiceNameMapping.getAndListen(metadataServiceNameMapping.java:107) ~[dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.metadata.AbstractServiceNameMapping.getAndListenServices(AbstractServiceNameMapping.java:101) ~[dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.doSubscribe(ServiceDiscoveryRegistry.java:215) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribe(ServiceDiscoveryRegistry.java:204) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.ListenerRegistryWrapper.subscribe(ListenerRegistryWrapper.java:109) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.DynamicDirectory.subscribe(DynamicDirectory.java:160) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.subscribe(ServiceDiscoveryRegistryDirectory.java:104) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.RegistryProtocol.doCreateInvoker(RegistryProtocol.java:557) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.InterfaceCompatibleRegistryProtocol.getServiceDiscoveryInvoker(InterfaceCompatibleRegistryProtocol.java:65) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationInvoker.refreshServiceDiscoveryInvoker(MigrationInvoker.java:424) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationInvoker.migrateToApplicationFirstInvoker(MigrationInvoker.java:240) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.refreshInvoker(MigrationRuleHandler.java:72) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.doMigrate(MigrationRuleHandler.java:56) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.client.migration.MigrationRuleListener.onRefer(MigrationRuleListener.java:233) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.RegistryProtocol.interceptInvoker(RegistryProtocol.java:526) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:495) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:480) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:83) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:74) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:71) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.refer(ProtocolSerializationWrapper.java:52) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.ReferenceConfig.createInvokerForRemote(ReferenceConfig.java:469) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:380) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:267) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:204) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.spring.ReferenceBean.getCallProxy(ReferenceBean.java:348) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.spring.ReferenceBean.access0(ReferenceBean.java:98) [dubbo-3.0.3.jar:3.0.3]
	at org.apache.dubbo.config.spring.ReferenceBean$DubboReferenceLazyInitTargetSource.createObject(ReferenceBean.java:355) [dubbo-3.0.3.jar:3.0.3]
	at org.springframework.aop.target.AbstractLazyCreationTargetSource.getTarget(AbstractLazyCreationTargetSource.java:88) [spring-aop-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192) [spring-aop-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at com.sun.proxy.$Proxy142.listByUntreated(Unknown Source) [na:na]
	at tm.mye.mobile.rpc.server.GroupMeetingServiceImpl.getMeetingRecordingByUntreated(GroupMeetingServiceImpl.java:192) [classes/:na]
	at tm.mye.mobile.uap.server.TaskService.scheduleTask(TaskService.java:41) [classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$Lifecyclemetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:415) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1786) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean
dubbo:
  registry:
    address: nacos://127.0.0.1:8848
  # 配置dubbo 元数据
  metadata-report:
    address: nacos://127.0.0.1:8848
    group: demo
(AbstractBeanFactory.java:324) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeanByName(AbstractAutowireCapableBeanFactory.java:453) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:527) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:497) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:650) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.annotation.Injectionmetadata$InjectedElement.inject(Injectionmetadata.java:229) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.annotation.Injectionmetadata.inject(Injectionmetadata.java:119) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:318) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean(AbstractBeanFactory.java:324) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeanByName(AbstractAutowireCapableBeanFactory.java:453) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:527) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:497) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:650) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.annotation.Injectionmetadata$InjectedElement.inject(Injectionmetadata.java:229) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.annotation.Injectionmetadata.inject(Injectionmetadata.java:119) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:318) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean(AbstractBeanFactory.java:324) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) [spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE] at tm.mye.mobile.MobileApiApplication.main(MobileApiApplication.java:20) ~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.3.6.RELEASE.jar:2.3.6.RELEASE]

解决metadata report 初始化错误:
修改项目 application.yml

元数据中心用于存储一些服务提供者、消费者的信息,比如dubbo版本、服务接口的信息(包括方法名、形参表、返回值类型)等等。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5686500.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存