Failed to check the status of the service com.zbcx.demo.service.UserService. No provider available

女爷i 2023-06-17 15:00 113阅读 0赞

Failed to check the status of the service com.zbcx.demo.service.UserService. No provider available for the service com.zbcx.demo.service.UserService from the url zookeeper

初学dubbox遇到的第一个错误,启动消费方时报此异常

  1. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController' defined in file [F:\Eclipse_Projects\dubboxdemo-web\target\classes\com\zbcx\demo\web\UserController.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanInitializationException: Failed to init remote service reference at filed userService in class com.zbcx.demo.web.UserController; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.zbcx.demo.service.UserService. No provider available for the service com.zbcx.demo.service.UserService from the url zookeeper://192.168.25.129:2181/com.alibaba.dubbo.registry.RegistryService?application=dubboxdemo-web&dubbo=2.8.4&interface=com.zbcx.demo.service.UserService&methods=getName&pid=14112&side=consumer&timestamp=1575012122973 to the consumer 192.168.2.108 use dubbo version 2.8.4
  2. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
  3. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
  4. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
  5. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
  6. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
  7. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
  8. at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
  9. at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
  10. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
  11. at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
  12. at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
  13. at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
  14. at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
  15. at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
  16. at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
  17. at javax.servlet.GenericServlet.init(GenericServlet.java:160)
  18. at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
  19. at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
  20. at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
  21. at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
  22. at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
  23. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  24. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
  25. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
  26. at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  27. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  28. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  29. at java.lang.Thread.run(Thread.java:748)
  30. Caused by: org.springframework.beans.factory.BeanInitializationException: Failed to init remote service reference at filed userService in class com.zbcx.demo.web.UserController; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.zbcx.demo.service.UserService. No provider available for the service com.zbcx.demo.service.UserService from the url zookeeper://192.168.25.129:2181/com.alibaba.dubbo.registry.RegistryService?application=dubboxdemo-web&dubbo=2.8.4&interface=com.zbcx.demo.service.UserService&methods=getName&pid=14112&side=consumer&timestamp=1575012122973 to the consumer 192.168.2.108 use dubbo version 2.8.4
  31. at com.alibaba.dubbo.config.spring.AnnotationBean.postProcessBeforeInitialization(AnnotationBean.java:253)
  32. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
  33. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
  34. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
  35. ... 27 more
  36. Caused by: java.lang.IllegalStateException: Failed to check the status of the service com.zbcx.demo.service.UserService. No provider available for the service com.zbcx.demo.service.UserService from the url zookeeper://192.168.25.129:2181/com.alibaba.dubbo.registry.RegistryService?application=dubboxdemo-web&dubbo=2.8.4&interface=com.zbcx.demo.service.UserService&methods=getName&pid=14112&side=consumer&timestamp=1575012122973 to the consumer 192.168.2.108 use dubbo version 2.8.4
  37. at com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:420)
  38. at com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:300)
  39. at com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:138)
  40. at com.alibaba.dubbo.config.spring.AnnotationBean.refer(AnnotationBean.java:317)
  41. at com.alibaba.dubbo.config.spring.AnnotationBean.postProcessBeforeInitialization(AnnotationBean.java:246)
  42. ... 30 more
  43. 十一月 29, 2019 3:22:03 下午 org.apache.catalina.core.StandardContext loadOnStartup
  44. 严重: Servlet threw load() exception
  45. java.lang.IllegalStateException: Failed to check the status of the service com.zbcx.demo.service.UserService. No provider available for the service com.zbcx.demo.service.UserService from the url zookeeper://192.168.25.129:2181/com.alibaba.dubbo.registry.RegistryService?application=dubboxdemo-web&dubbo=2.8.4&interface=com.zbcx.demo.service.UserService&methods=getName&pid=14112&side=consumer&timestamp=1575012122973 to the consumer 192.168.2.108 use dubbo version 2.8.4
  46. at com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:420)
  47. at com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:300)
  48. at com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:138)
  49. at com.alibaba.dubbo.config.spring.AnnotationBean.refer(AnnotationBean.java:317)
  50. at com.alibaba.dubbo.config.spring.AnnotationBean.postProcessBeforeInitialization(AnnotationBean.java:246)
  51. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
  52. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
  53. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
  54. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
  55. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
  56. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
  57. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
  58. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
  59. at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
  60. at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
  61. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
  62. at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
  63. at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
  64. at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
  65. at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
  66. at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
  67. at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
  68. at javax.servlet.GenericServlet.init(GenericServlet.java:160)
  69. at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
  70. at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
  71. at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
  72. at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
  73. at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
  74. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  75. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
  76. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
  77. at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  78. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  79. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  80. at java.lang.Thread.run(Thread.java:748)

此错误原因是编写服务方servcie时,写错了注解,应该使用dubbox提供的注解,不应该用spring的service注解

  1. **import org.springframework.stereotype.Service;**
  2. import com.zbcx.demo.service.UserService;
  3. @Service
  4. public class UserServiceImpl implements UserService{
  5. public String getName() {
  6. // TODO Auto-generated method stub
  7. return "zbcx";
  8. }
  9. }

解决办法
将service注解改为dubbo官方注解

  1. **import com.alibaba.dubbo.config.annotation.Service;**
  2. import com.zbcx.demo.service.UserService;
  3. @Service
  4. public class UserServiceImpl implements UserService{
  5. public String getName() {
  6. // TODO Auto-generated method stub
  7. return "zbcx";
  8. }
  9. }

发表评论

表情:
评论列表 (有 0 条评论,113人围观)

还没有评论,来说两句吧...

相关阅读