zoukankan      html  css  js  c++  java
  • No provider available for the service com.xxx.xxx 错误解决

    HTTP Status 500 - Servlet.init() for servlet springmvc threw exception

    type Exception report
    
    message Servlet.init() for servlet springmvc threw exception
    
    description The server encountered an internal error that prevented it from fulfilling this request.
    
    exception
    
    javax.servlet.ServletException: Servlet.init() for servlet springmvc threw exception
    	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    	org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    	org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
    	org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
    	org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	java.lang.Thread.run(Thread.java:748)
    root cause
    
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cartController' defined in file [D:workspacepinyougou_parentpinyougou_cart_web	argetclassescompinyougoucartcontrollerCartController.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanInitializationException: Failed to init remote service reference at filed cartService in class com.pinyougou.cart.controller.CartController; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.pinyougou.cart.service.CartService. **No provider available** for the service com.pinyougou.cart.service.CartService from the url zookeeper://192.168.25.133:2181/com.alibaba.dubbo.registry.RegistryService?anyhost=true&application=pinyougou_cart_web&check=false&dubbo=2.8.4&generic=false&interface=com.pinyougou.cart.service.CartService&methods=addGoodsToCartList&pid=12688&revision=1.0-SNAPSHOT&side=consumer&timestamp=1575554801235 to the consumer 192.168.56.1 use dubbo version 2.8.4
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    	org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
    	org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
    	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
    	org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
    	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
    	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
    	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
    	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
    	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    	javax.servlet.GenericServlet.init(GenericServlet.java:160)
    	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    	org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    	org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
    	org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
    	org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	java.lang.Thread.run(Thread.java:748)
    

    登录 Dubbo 发现确实没有提供者

    但是我的service服务是启动成功了呀

    最后发现原来是我的service 的web.xml没有配置

    将web.xml配置好之后,重新启动服务即可,这时候提供者就有了

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
             version="2.5">
        <display-name>pinyougou_user_service</display-name>
    
        <!-- 加载spring容器 -->
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath*:spring/applicationContext*.xml</param-value>
        </context-param>
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
    </web-app>
    

    所以总结:

    • 当出现No provider available for the service的时候,先检查自己的service提供者是否真的已经成功启动,如果启动成功了,还是报这个错误,再检查一下自己的 xml配置文件,需要配置对才能提供服务.
    • 另外,还有一个需要注意的地方,@Service 和 @Reference 这两个的注解需要是 com.alibaba.dubbo.config.annotation 包下的才行
  • 相关阅读:
    WPF 调用WINForm中的ColorDialog
    WPF 获取ControlTemplate 中的控件方法
    <转> 8个超棒的免费高质量图标搜索引擎
    WPF 右键菜单动画
    WPF 创建超级连接
    WPF 数据模板的切换简单事例
    WPF 关于ShowDialog后主窗体依然能响应键盘输入法的解决方案。
    <转>强制类型转换总结
    WPF 中的MessageBox返回值获取并判断
    WPF数据绑定实现自定义数据源
  • 原文地址:https://www.cnblogs.com/tangjian07/p/11992436.html
Copyright © 2011-2022 走看看