Dubbo常见问题

Posted on 2018-02-12 17:55  cuilupeng  阅读(910)  评论(0)    收藏  举报
1. dubbo No provider available for the service com.alibaba.dubbo.monitor.MonitorService from registry

* 原因:没有启动SimpleMonitor,或SimpleMonitor没有连上Zookeeper注册中心
* 解决方案:在消费者配置文件中注释掉<dubbo:monitor protocol="registry" />

2. Caused by: java.lang.IllegalStateException: Context namespace element 'annotation-config' and its parser class [org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser] are only available on JDK 1.5 and higher
* 原因解释: http://stackoverflow.com/questions/23813369/spring-java-error-namespace-element-annotation-config-on-jdk-1-5-and-high
因为使用了 jdk1.8, 而dubbo 依赖 Spring 2.5 ,而Spring2.5仅仅支持 jdk1.5 到 jdk 1.7, 所以jdk 1.8 不被识别,所以报错。

3. 启动时报错 Caused by: java.lang.reflect.MalformedParameterizedTypeException
* 原因:dubbo 依赖 spring 2.5.6.SEC03,而我项目中有用spring 3.2.4.RELEASE,所以导致冲突。
* 解决方案:在maven中把dubbo中的spring依赖去除就可以了。
如果你们项目中也报这个错,很可能也是因为jar包冲突造成的

  <dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>dubbo</artifactId>
    <exclusions> 
        <exclusion> 
            <artifactId>spring</artifactId> 
            <groupId>org.springframework</groupId> 
        </exclusion> 
    </exclusions> 
   </dependency>

4. 出现com.alibaba.dubbo.registry.internal.rpc.exception.RpcLocalExceptionIoTargetIsNotConnected怎么办?
* 解决方案
1). 检查注册中心是否开启白名单功能,如果开启,当IP不在白名单列表中,注册中心将拒绝连接。
2). 检查端口是否正确,注册中心有两个端口,一个为控制台HTTP端口,用于管理员查看数据,一个为程序注册服务用的TCP端口。
5. 出现Remote server returns error: [6], Got invocation exception怎么办?
* 解决方案:此异常表示Dubbo框架调用服务提供者的实现方法失败,并且不是方法本身的业务异常。
通常是服务消费者和服务提供者的API签名不一致引起,或者提供方比消费方少此函数。
一般是服务增加方法,或修改了方法签名,而双方用的服务API的jar包不一致。

6. 出现 Caused by: com.alibaba.dubbo.remoting.TimeoutException: Waiting server-side response timeout by scan timer.
* 解决方案: 
简单来说就是dubbo超时,因为dubbo默认的时间是500ms,超过这个时间它会重新访问service层,最多尝试三次。
所以我在测试的时候日志显示出来的异常为……timeout……。
开始设置开始设置的timeout=50000,小数据量可以,如果数据量比较大就不行了。
后来在服务提供端设置timeout=1200000
  并且加了timeout属性的配置因该放在最后一条,否则回合配置冲突。  
  1)客户端添加timeout会造成tomcat启动延时。  
   <dubbo:service interface="com.XXXX.XXXXX.CardService" ref="cardService" timeout="1200000"/>

  2)另外一种是全局新修改的办法(timeout时间可以自己调整)  
    <dubbo:provider delay="-1" timeout="6000" retries="0"/>

7. com.alibaba.dubbo.rpc.RpcException: Forbid consumer 10.2.1.181 access service com.wiwj.cbs.base.api.ApiConfigService from registry 10.2.1.24:2181 use dubbo version 2.5.3, Please check registry access list (whitelist/blacklist).
* 删除掉重复的服务引用,考虑是否重复定义服务,或重复引用

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3