dubbo应用自产自消报错?

背景:一个应用使用dubbo,自己提供的服务,自己去调。(不要问我干嘛通过dubbo去掉自己的服务)
实践一:启动一个spring容器,加载dubbo容器,注册并使用dubbo服务。
启动容器
ClassPathXmlApplicationContextcontext=newClassPathXmlApplicationContext(newString[]{"classpath:provider.xml"});
context.start();
HiDubboFacadeo1=(HiDubboFacade)context.getBean("hiDubboFacade");
Strings1=o1.hi("xxt11111");
System.out.println(s1);
System.out.println("reference1hashcode:"+o1.hashCode());
HiDubboFacadeo2=(HiDubboFacade)context.getBean("helloDubbo");
Strings2=o2.hi("xxt");
System.out.println(s2);
System.out.println("reference2hashcode:"+o2.hashCode());
没有问题:
ireceivedmsg:xxt11111
reference1hashcode:352598575
[2017-07-2016:27:59.659][main][INFO][c.a.dubbo.config.AbstractConfig]-[DUBBO]Usinginjvmservicecom.coder4j.job.facade.HiDubboFacade,dubboversion:2.5.3,currenthost:127.0.0.1
[2017-07-2016:27:59.659][main][INFO][c.a.dubbo.config.AbstractConfig]-[DUBBO]Referdubboservicecom.coder4j.job.facade.HiDubboFacadefromurlinjvm://127.0.0.1/com.coder4j.job.facade.HiDubboFacade?application=app&dubbo=2.5.3&interface=com.coder4j.job.facade.HiDubboFacade&methods=hi&pid=11220&side=consumer×tamp=1500539279654,dubboversion:2.5.3,currenthost:127.0.0.1
ireceivedmsg:xxt
referencehashcode:1873091796
实践二:使用相同的配置,在web应用中启动,就拿不到helloDubbo,报错。
Causedby:org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'helloDubbo':FactoryBeanthrewexceptiononobjectcreation;nestedexceptionisjava.lang.IllegalStateException:Failedtocheckthestatusoftheservicecom.coder4j.job.facade.HiDubboFacade.Noprovideravailablefortheservicecom.coder4j.job.facade.HiDubboFacadefromtheurlregistry://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=app&cluster=available&dubbo=2.5.3&pid=13008&refer=application%3Dapp%26dubbo%3D2.5.3%26interface%3Dcom.coder4j.job.facade.HiDubboFacade%26methods%3Dtell%2Chello%26pid%3D13008%26revision%3D1.0.0%26side%3Dconsumer%26timestamp%3D1500532931746®istry=zookeeper×tamp=1500532931788totheconsumer192.168.23.144usedubboversion2.5.3
atorg.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175)
atorg.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
atorg.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1634)
atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:254)
atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
atorg.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081)
atcom.coder4j.job.integration.MyIntegration.setApplicationContext(MyIntegration.java:61)
atorg.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:121)
atorg.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:97)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1620)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
...20more
Causedby:java.lang.IllegalStateException:Failedtocheckthestatusoftheservicecom.coder4j.job.facade.HiDubboFacade.Noprovideravailablefortheservicecom.coder4j.job.facade.HiDubboFacadefromtheurlregistry://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=app&cluster=available&dubbo=2.5.3&pid=13008&refer=application%3Dapp%26dubbo%3D2.5.3%26interface%3Dcom.coder4j.job.facade.HiDubboFacade%26methods%3Dtell%2Chello%26pid%3D13008%26revision%3D1.0.0%26side%3Dconsumer%26timestamp%3D1500532931746®istry=zookeeper×tamp=1500532931788totheconsumer192.168.23.144usedubboversion2.5.3
atcom.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:420)
atcom.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:300)
atcom.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:138)
atcom.alibaba.dubbo.config.spring.ReferenceBean.getObject(ReferenceBean.java:65)
atorg.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
...31more
实践三:如果我单独启动一个springjava容器,将服务注册到zookeeper,再启动一个web应用是可以拿到java容器发布的服务的。
请问,在web应用中,自己发布的服务,自己不能够消费嘛????
潇潇雨雨
浏览 368回答 2
2回答

一只名叫tom的猫

我只能说很有可能是springmvc和spring的容器问题,dubbo中的对象是在spring容器中的,springmvc可能拿不到
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript