-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
一直提示 Unsupported protocol rest in notified url ,定位了好久了,不知道是不是dubbox 2.8.4 的问题 #73
Comments
我也遇到了一样的问题
provide配置 <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<!-- 启用spring mvc 注解 -->
<context:annotation-config/>
<!-- 设置使用注解的类所在的jar包 -->
<context:component-scan base-package="com.bc.qss.search"></context:component-scan>
<!-- 当前应用信息配置 -->
<dubbo:application name="qss-search-service"/>
<!-- 暴露服务协议配置
name协议名称,port暴露端口 http://dubbo.io/Protocol+Config-zh.htm-->
<dubbo:protocol name="rest" port="9090" server="tomcat" contextpath="search_service"
extension="com.bc.qss.search.api.extension.CustomExceptionMapper"/>
<!--dubbo 注册中心zookeeper单点/集群 http://dubbo.io/Zookeeper+Registry-zh.htm -->
<dubbo:registry address="zookeeper://127.0.0.1:2181"/>
<!--监控中心配置-->
<!--监控中心协议,如果为protocol="registry",表示从注册中心发现监控中心地址,否则直连监控中心。-->
<!--直连监控中心服务器地址,address="10.20.130.230:12080"-->
<dubbo:monitor protocol="registry"/>
<!--dubbo 服务提供者配置 interface class 必选
建议配置 version(版本号,便于升级)
retries(重试次数,默认2,非幂等操作必选设为0)
timeout(远程服务超时时间,默认1000)
connections(对每个提供者的最大连接数,rmi、http、hessian等短连接协议表示限制连接数,dubbo等长连接协表示建立的长连接个数)
更多设置参考 http://dubbo.io/Service+Config-zh.htm
-->
<dubbo:service interface="com.bc.qss.search.api.SearchService" ref="searchService"
version="1.0"
owner="two8g"
protocol="rest"/>
<!--service 实现 bean-->
<bean id="searchService" class="com.bc.qss.search.service.SearchServiceImpl"/>
</beans> consumer配置 <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- 当前应用信息配置 -->
<dubbo:application name="qss-search-consumer" owner="two8g"/>
<!--dubbo 注册中心zookeeper单点/集群 http://dubbo.io/Zookeeper+Registry-zh.htm -->
<dubbo:registry address="zookeeper://127.0.0.1:2181"/>
<!--监控中心配置-->
<!--监控中心协议,如果为protocol="registry",表示从注册中心发现监控中心地址,否则直连监控中心。-->
<!--直连监控中心服务器地址,address="10.20.130.230:12080"-->
<dubbo:monitor protocol="registry"/>
<!--消费者服务代理配置 id,interface必选 http://dubbo.io/Reference+Config-zh.htm http://dubbo.io/Consumer+Config-zh.htm-->
<dubbo:reference id="searchService" interface="com.bc.qss.search.api.SearchService" version="1.0" owner="two8g"/>
</beans> |
好像意思是consumer无法支持提供者的rest协议。因为我的唯一一个提供者是以rest协议暴露服务的。 |
找到问题所在了,使用rest之前忽略看说明文档的下面这段了. 场景2:dubbo消费端调用dubbo的REST服务 这种场景下,和使用其他dubbo的远程调用方式一样,直接在服务提供端和服务消费端共享Java服务接口,并添加spring xml配置(当然也可以用spring/dubbo的annotation配置),即可透明的调用远程REST服务: <dubbo:reference id="userService" interface="xxx.UserService"/> 如前所述,这种场景下必须把JAX-RS的annotation添加到服务接口上,这样在dubbo在消费端才能共享相应的REST配置信息,并据之做远程调用: @Path("users")
public interface UserService {
@GET
@Path("{id : \\d+}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
User getUser(@PathParam("id") Long id);
} 问题就在JAX-RS的annotation添加到服务接口上,而我把注解添加到了服务提供者的实现上.索引服务消费者无法调用。等我改回来,测试后,再来回答修改后的结果 |
修改注解位置后仍然报rest协议不支持的错误。到底是哪的问题???
|
重要找到问题所在了,原来是缺少以下jboss相关依赖包: <dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-netty</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jdk-http</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
</dependency> |
@two8g 你好,我遇到和你一样的问题,按照你说的已经解决问题了。不过我有一点疑问:
你从这个问题是怎样发现缺少了这些依赖的?我从错误信息完全看不出来缺了这些依赖。。。 |
HTTP REST 是dubbox的扩展功能,http://dangdangdotcom.github.io/dubbox/ 中写了:
|
8:06:52.575 ERROR com.alibaba.dubbo.registry.integration.RegistryDirectory - Unsupported protocol rest in notified url: rest://192.168.2.186:8181/com.qbao.bbs.resources.interfaces.FocusMapInterface?accepts=500&anyhost=true&application=bbs_api_provider&dubbo=2.8.4&extension=com.planetj.servlet.filter.compression.CompressingFilter, com.qbao.bbs.exception.ExceptionMapperSupport, com.alibaba.dubbo.rpc.protocol.rest.support.LoggingFilter&generic=false&interface=com.qbao.bbs.resources.interfaces.FocusMapInterface&methods=update,findByID,delete,create,findList&pid=4853&server=tomcat&side=provider&threads=500×tamp=1452144536206&validation=true from registry 192.168.2.236:2181 to consumer 192.168.2.186, supported protocol: [dubbo, http, injvm, mock, redis, registry, rmi, thrift]
java.lang.IllegalStateException: Unsupported protocol rest in notified url: rest://192.168.2.186:8181/com.qbao.bbs.resources.interfaces.FocusMapInterface?accepts=500&anyhost=true&application=bbs_api_provider&dubbo=2.8.4&extension=com.planetj.servlet.filter.compression.CompressingFilter, com.qbao.bbs.exception.ExceptionMapperSupport, com.alibaba.dubbo.rpc.protocol.rest.support.LoggingFilter&generic=false&interface=com.qbao.bbs.resources.interfaces.FocusMapInterface&methods=update,findByID,delete,create,findList&pid=4853&server=tomcat&side=provider&threads=500×tamp=1452144536206&validation=true from registry 192.168.2.236:2181 to consumer 192.168.2.186, supported protocol: [dubbo, http, injvm, mock, redis, registry, rmi, thrift]
The text was updated successfully, but these errors were encountered: