Open xutianlong opened 8 years ago
我也遇到了一样的问题 错误信息:
[14/04/16 12:21:11:011 CST] localhost-startStop-1 ERROR integration.RegistryDirectory: Unsupported protocol rest in notified url: rest://10.1.1.121:9090/search_service/com.bc.qss.search.api.SearchService?anyhost=true&application=qss-search-service&dubbo=2.8.4&extension=com.bc.qss.search.api.extension.CustomExceptionMapper&generic=false&interface=com.bc.qss.search.api.SearchService&loadbalance=roundrobin&methods=searchQuestByBase64,searchQuestByImage,searchQuestByURI,searchQuestByText&owner=two8g&pid=15866&revision=1.0&server=tomcat&side=provider×tamp=1460605486315&version=1.0 from registry 127.0.0.1:2181 to consumer 10.1.1.121, supported protocol: [dubbo, http, injvm, mock, redis, registry, rmi, thrift]
java.lang.IllegalStateException: Unsupported protocol rest in notified url: rest://10.1.1.121:9090/search_service/com.bc.qss.search.api.SearchService?anyhost=true&application=qss-search-service&dubbo=2.8.4&extension=com.bc.qss.search.api.extension.CustomExceptionMapper&generic=false&interface=com.bc.qss.search.api.SearchService&loadbalance=roundrobin&methods=searchQuestByBase64,searchQuestByImage,searchQuestByURI,searchQuestByText&owner=two8g&pid=15866&revision=1.0&server=tomcat&side=provider×tamp=1460605486315&version=1.0 from registry 127.0.0.1:2181 to consumer 10.1.1.121, supported protocol: [dubbo, http, injvm, mock, redis, registry, rmi, thrift]
at com.alibaba.dubbo.registry.integration.RegistryDirectory.toInvokers(RegistryDirectory.java:372)
at com.alibaba.dubbo.registry.integration.RegistryDirectory.refreshInvoker(RegistryDirectory.java:224)
at com.alibaba.dubbo.registry.integration.RegistryDirectory.notify(RegistryDirectory.java:195)
at com.alibaba.dubbo.registry.support.AbstractRegistry.notify(AbstractRegistry.java:449)
at com.alibaba.dubbo.registry.support.FailbackRegistry.doNotify(FailbackRegistry.java:273)
at com.alibaba.dubbo.registry.support.FailbackRegistry.notify(FailbackRegistry.java:259)
at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doSubscribe(ZookeeperRegistry.java:170)
at com.alibaba.dubbo.registry.support.FailbackRegistry.subscribe(FailbackRegistry.java:189)
at com.alibaba.dubbo.registry.integration.RegistryDirectory.subscribe(RegistryDirectory.java:133)
at com.alibaba.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:271)
at com.alibaba.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:254)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:60)
at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:63)
at com.alibaba.dubbo.rpc.Protocol$Adpative.refer(Protocol$Adpative.java)
at com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:392)
at com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:300)
at com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:138)
at com.alibaba.dubbo.config.spring.ReferenceBean.getObject(ReferenceBean.java:65)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1590)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:254)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4738)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5181)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1798)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[14/04/16 12:21:11:011 CST] localhost-startStop-1 ERROR context.ContextLoader: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'searchController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.bc.qss.search.api.SearchService com.bc.qss.search.consumer.controller.SearchController.searchService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'searchService': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.bc.qss.search.api.SearchService. No provider available for the service com.bc.qss.search.api.SearchService:1.0 from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=qss-search-consumer&dubbo=2.8.4&interface=com.bc.qss.search.api.SearchService&methods=searchQuestByURI,searchQuestByImage,searchQuestByBase64,searchQuestByText&owner=two8g&pid=18267&revision=1.0&side=consumer×tamp=1460607671324&version=1.0 to the consumer 10.1.1.121 use dubbo version 2.8.4
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4738)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5181)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1798)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.bc.qss.search.api.SearchService com.bc.qss.search.consumer.controller.SearchController.searchService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'searchService': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.bc.qss.search.api.SearchService. No provider available for the service com.bc.qss.search.api.SearchService:1.0 from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=qss-search-consumer&dubbo=2.8.4&interface=com.bc.qss.search.api.SearchService&methods=searchQuestByURI,searchQuestByImage,searchQuestByBase64,searchQuestByText&owner=two8g&pid=18267&revision=1.0&side=consumer×tamp=1460607671324&version=1.0 to the consumer 10.1.1.121 use dubbo version 2.8.4
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 26 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'searchService': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.bc.qss.search.api.SearchService. No provider available for the service com.bc.qss.search.api.SearchService:1.0 from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=qss-search-consumer&dubbo=2.8.4&interface=com.bc.qss.search.api.SearchService&methods=searchQuestByURI,searchQuestByImage,searchQuestByBase64,searchQuestByText&owner=two8g&pid=18267&revision=1.0&side=consumer×tamp=1460607671324&version=1.0 to the consumer 10.1.1.121 use dubbo version 2.8.4
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1590)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:254)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
... 28 more
Caused by: java.lang.IllegalStateException: Failed to check the status of the service com.bc.qss.search.api.SearchService. No provider available for the service com.bc.qss.search.api.SearchService:1.0 from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=qss-search-consumer&dubbo=2.8.4&interface=com.bc.qss.search.api.SearchService&methods=searchQuestByURI,searchQuestByImage,searchQuestByBase64,searchQuestByText&owner=two8g&pid=18267&revision=1.0&side=consumer×tamp=1460607671324&version=1.0 to the consumer 10.1.1.121 use dubbo version 2.8.4
at com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:420)
at com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:300)
at com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:138)
at com.alibaba.dubbo.config.spring.ReferenceBean.getObject(ReferenceBean.java:65)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
... 36 more
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协议暴露服务的。 那请问dubbox新增的rest协议能否提供给dubbo项目消费者使用?
找到问题所在了,使用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协议不支持的错误。到底是哪的问题???
[14/04/16 07:55:52:052 CST] localhost-startStop-1 ERROR integration.RegistryDirectory: Unsupported protocol rest in notified url: rest://10.1.1.121:9090/search_service/com.bc.qss.search.api.SearchRestService?anyhost=true&application=qss-search-service&dubbo=2.8.4&extension=com.bc.qss.search.api.extension.CustomExceptionMapper&generic=false&interface=com.bc.qss.search.api.SearchRestService&loadbalance=roundrobin&methods=searchQuestByBase64,searchQuestByImage,searchQuestByURI,searchQuestByText&owner=two8g&pid=3641&revision=1.0&server=tomcat&side=provider×tamp=1460634363655&version=1.0 from registry 127.0.0.1:2181 to consumer 10.1.1.121, supported protocol: [dubbo, http, injvm, mock, redis, registry, rmi, thrift]
java.lang.IllegalStateException: Unsupported protocol rest in notified url: rest://10.1.1.121:9090/search_service/com.bc.qss.search.api.SearchRestService?anyhost=true&application=qss-search-service&dubbo=2.8.4&extension=com.bc.qss.search.api.extension.CustomExceptionMapper&generic=false&interface=com.bc.qss.search.api.SearchRestService&loadbalance=roundrobin&methods=searchQuestByBase64,searchQuestByImage,searchQuestByURI,searchQuestByText&owner=two8g&pid=3641&revision=1.0&server=tomcat&side=provider×tamp=1460634363655&version=1.0 from registry 127.0.0.1:2181 to consumer 10.1.1.121, supported protocol: [dubbo, http, injvm, mock, redis, registry, rmi, thrift]
at com.alibaba.dubbo.registry.integration.RegistryDirectory.toInvokers(RegistryDirectory.java:372)
at com.alibaba.dubbo.registry.integration.RegistryDirectory.refreshInvoker(RegistryDirectory.java:224)
at com.alibaba.dubbo.registry.integration.RegistryDirectory.notify(RegistryDirectory.java:195)
at com.alibaba.dubbo.registry.support.AbstractRegistry.notify(AbstractRegistry.java:449)
at com.alibaba.dubbo.registry.support.FailbackRegistry.doNotify(FailbackRegistry.java:273)
at com.alibaba.dubbo.registry.support.FailbackRegistry.notify(FailbackRegistry.java:259)
at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doSubscribe(ZookeeperRegistry.java:170)
at com.alibaba.dubbo.registry.support.FailbackRegistry.subscribe(FailbackRegistry.java:189)
at com.alibaba.dubbo.registry.integration.RegistryDirectory.subscribe(RegistryDirectory.java:133)
at com.alibaba.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:271)
at com.alibaba.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:254)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:60)
at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:63)
at com.alibaba.dubbo.rpc.Protocol$Adpative.refer(Protocol$Adpative.java)
at com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:392)
at com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:300)
at com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:138)
at com.alibaba.dubbo.config.spring.ReferenceBean.getObject(ReferenceBean.java:65)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1590)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:512)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:486)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:615)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:169)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4738)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5181)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1798)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[14/04/16 07:55:52:052 CST] localhost-startStop-1 ERROR integration.RegistryDirectory: urls to invokers error .invokerUrls.size :1, invoker.size :0. urls :[rest://10.1.1.121:9090/search_service/com.bc.qss.search.api.SearchRestService?anyhost=true&application=qss-search-service&dubbo=2.8.4&extension=com.bc.qss.search.api.extension.CustomExceptionMapper&generic=false&interface=com.bc.qss.search.api.SearchRestService&loadbalance=roundrobin&methods=searchQuestByBase64,searchQuestByImage,searchQuestByURI,searchQuestByText&owner=two8g&pid=3641&revision=1.0&server=tomcat&side=provider×tamp=1460634363655&version=1.0]
java.lang.IllegalStateException: urls to invokers error .invokerUrls.size :1, invoker.size :0. urls :[rest://10.1.1.121:9090/search_service/com.bc.qss.search.api.SearchRestService?anyhost=true&application=qss-search-service&dubbo=2.8.4&extension=com.bc.qss.search.api.extension.CustomExceptionMapper&generic=false&interface=com.bc.qss.search.api.SearchRestService&loadbalance=roundrobin&methods=searchQuestByBase64,searchQuestByImage,searchQuestByURI,searchQuestByText&owner=two8g&pid=3641&revision=1.0&server=tomcat&side=provider×tamp=1460634363655&version=1.0]
at com.alibaba.dubbo.registry.integration.RegistryDirectory.refreshInvoker(RegistryDirectory.java:229)
at com.alibaba.dubbo.registry.integration.RegistryDirectory.notify(RegistryDirectory.java:195)
at com.alibaba.dubbo.registry.support.AbstractRegistry.notify(AbstractRegistry.java:449)
at com.alibaba.dubbo.registry.support.FailbackRegistry.doNotify(FailbackRegistry.java:273)
at com.alibaba.dubbo.registry.support.FailbackRegistry.notify(FailbackRegistry.java:259)
at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doSubscribe(ZookeeperRegistry.java:170)
at com.alibaba.dubbo.registry.support.FailbackRegistry.subscribe(FailbackRegistry.java:189)
at com.alibaba.dubbo.registry.integration.RegistryDirectory.subscribe(RegistryDirectory.java:133)
at com.alibaba.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:271)
at com.alibaba.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:254)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:60)
at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:63)
at com.alibaba.dubbo.rpc.Protocol$Adpative.refer(Protocol$Adpative.java)
at com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:392)
at com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:300)
at com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:138)
at com.alibaba.dubbo.config.spring.ReferenceBean.getObject(ReferenceBean.java:65)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1590)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:512)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:486)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:615)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:169)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4738)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5181)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1798)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[14/04/16 07:55:52:052 CST] localhost-startStop-1 WARN support.XmlWebApplicationContext: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'searchController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'searchRestService': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.bc.qss.search.api.SearchRestService. No provider available for the service com.bc.qss.search.api.SearchRestService:1.0 from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=qss-search-consumer&dubbo=2.8.4&interface=com.bc.qss.search.api.SearchRestService&methods=searchQuestByURI,searchQuestByImage,searchQuestByBase64,searchQuestByText&owner=two8g&pid=4208&revision=1.0&side=consumer×tamp=1460634952184&version=1.0 to the consumer 10.1.1.121 use dubbo version 2.8.4
[14/04/16 07:55:52:052 CST] localhost-startStop-1 ERROR context.ContextLoader: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'searchController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'searchRestService': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.bc.qss.search.api.SearchRestService. No provider available for the service com.bc.qss.search.api.SearchRestService:1.0 from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=qss-search-consumer&dubbo=2.8.4&interface=com.bc.qss.search.api.SearchRestService&methods=searchQuestByURI,searchQuestByImage,searchQuestByBase64,searchQuestByText&owner=two8g&pid=4208&revision=1.0&side=consumer×tamp=1460634952184&version=1.0 to the consumer 10.1.1.121 use dubbo version 2.8.4
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:311)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4738)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5181)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1798)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'searchRestService': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.bc.qss.search.api.SearchRestService. No provider available for the service com.bc.qss.search.api.SearchRestService:1.0 from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=qss-search-consumer&dubbo=2.8.4&interface=com.bc.qss.search.api.SearchRestService&methods=searchQuestByURI,searchQuestByImage,searchQuestByBase64,searchQuestByText&owner=two8g&pid=4208&revision=1.0&side=consumer×tamp=1460634952184&version=1.0 to the consumer 10.1.1.121 use dubbo version 2.8.4
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1590)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:512)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:486)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:615)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:169)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:308)
... 26 more
Caused by: java.lang.IllegalStateException: Failed to check the status of the service com.bc.qss.search.api.SearchRestService. No provider available for the service com.bc.qss.search.api.SearchRestService:1.0 from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=qss-search-consumer&dubbo=2.8.4&interface=com.bc.qss.search.api.SearchRestService&methods=searchQuestByURI,searchQuestByImage,searchQuestByBase64,searchQuestByText&owner=two8g&pid=4208&revision=1.0&side=consumer×tamp=1460634952184&version=1.0 to the consumer 10.1.1.121 use dubbo version 2.8.4
at com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:420)
at com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:300)
at com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:138)
at com.alibaba.dubbo.config.spring.ReferenceBean.getObject(ReferenceBean.java:65)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
... 36 more
14-Apr-2016 19:55:52.612 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
14-Apr-2016 19:55:52.630 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [/qss-search-consumer-1.0] startup failed due to previous errors
重要找到问题所在了,原来是缺少以下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 你好,我遇到和你一样的问题,按照你说的已经解决问题了。不过我有一点疑问:
修改注解位置后仍然报rest协议不支持的错误。到底是哪的问题???
你从这个问题是怎样发现缺少了这些依赖的?我从错误信息完全看不出来缺了这些依赖。。。
HTTP REST 是dubbox的扩展功能,http://dangdangdotcom.github.io/dubbox/ 中写了:
支持REST风格远程调用(HTTP + JSON/XML):基于非常成熟的JBoss RestEasy框架
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]