yujing730 2021-11-24 18:08 采纳率: 100%
浏览 232
已结题

Dubbo入门 服务方报错 Error creating bean with name "" defined

xml配置文件


<?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">
    <!--1.服务提供方在zookeeper中的“别名”-->
    <dubbo:application name="dubbo-server"/>
    <!--2.注册中心的地址-->
    <dubbo:registry address="zookeeper://192.168.233.128:2181"/>
    <!--3.扫描类(将什么包下的类作为服务提供类)-->
    <dubbo:annotation package="service.impl"/>
</beans>

实现类


import com.alibaba.dubbo.config.annotation.Service;
import service.HelloService;

@Service
public class HelloServiceImpl implements HelloService {

    @Override
    public String sayHello(String name) {
        return "Hello," + name + "!!!";
    }
}

报错信息

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'helloServiceImpl' defined in file [D:\Workspace\zookeeper_code\dubbo-server\target\classes\service\impl\helloServiceImpl.class]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Failed to register dubbo://192.168.233.1:20880/service.HelloService?anyhost=true&application=dubbo-server&dubbo=2.5.7&generic=false&interface=service.HelloService&methods=sayHello&pid=3952&side=provider&timestamp=1637743546439 to registry 192.168.233.128:2181, cause: Failed to register dubbo://192.168.233.1:20880/service.HelloService?anyhost=true&application=dubbo-server&dubbo=2.5.7&generic=false&interface=service.HelloService&methods=sayHello&pid=3952&side=provider&timestamp=1637743546439 to zookeeper zookeeper://192.168.233.128:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-server&dubbo=2.5.7&interface=com.alibaba.dubbo.registry.RegistryService&pid=3952&timestamp=1637743546422, cause: Zookeeper is not connected yet!
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:587)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:409)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalStateException: Failed to register dubbo://192.168.233.1:20880/service.HelloService?anyhost=true&application=dubbo-server&dubbo=2.5.7&generic=false&interface=service.HelloService&methods=sayHello&pid=3952&side=provider&timestamp=1637743546439 to registry 192.168.233.128:2181, cause: Failed to register dubbo://192.168.233.1:20880/service.HelloService?anyhost=true&application=dubbo-server&dubbo=2.5.7&generic=false&interface=service.HelloService&methods=sayHello&pid=3952&side=provider&timestamp=1637743546439 to zookeeper zookeeper://192.168.233.128:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-server&dubbo=2.5.7&interface=com.alibaba.dubbo.registry.RegistryService&pid=3952&timestamp=1637743546422, cause: Zookeeper is not connected yet!
    at com.alibaba.dubbo.registry.support.FailbackRegistry.register(FailbackRegistry.java:149)
    at com.alibaba.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:120)
    at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:54)
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:92)
    at com.alibaba.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java)
    at com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:499)
    at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:351)
    at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:312)
    at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:211)
    at com.alibaba.dubbo.config.spring.AnnotationBean.postProcessAfterInitialization(AnnotationBean.java:191)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:437)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1710)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579)
    ... 20 more
Caused by: com.alibaba.dubbo.rpc.RpcException: Failed to register dubbo://192.168.233.1:20880/service.HelloService?anyhost=true&application=dubbo-server&dubbo=2.5.7&generic=false&interface=service.HelloService&methods=sayHello&pid=3952&side=provider&timestamp=1637743546439 to zookeeper zookeeper://192.168.233.128:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-server&dubbo=2.5.7&interface=com.alibaba.dubbo.registry.RegistryService&pid=3952&timestamp=1637743546422, cause: Zookeeper is not connected yet!
    at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doRegister(ZookeeperRegistry.java:112)
    at com.alibaba.dubbo.registry.support.FailbackRegistry.register(FailbackRegistry.java:136)
    ... 32 more
Caused by: java.lang.IllegalStateException: Zookeeper is not connected yet!
    at com.alibaba.dubbo.remoting.zookeeper.zkclient.ZkClientWrapper.createPersistent(ZkClientWrapper.java:82)
    at com.alibaba.dubbo.remoting.zookeeper.zkclient.ZkclientZookeeperClient.createPersistent(ZkclientZookeeperClient.java:45)
    at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:47)
    at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:41)
    at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:41)
    at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:41)
    at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doRegister(ZookeeperRegistry.java:110)
    ... 33 more

有没有人可以解答下

  • 写回答

1条回答 默认 最新

  • CSDN专家-sinJack 2021-11-24 18:13
    关注

    cause: Zookeeper is not connected yet!
    zookeeper连接不上,所属服务器的防火墙关掉。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录

报告相同问题?

问题事件

  • 系统已结题 12月2日
  • 已采纳回答 11月24日
  • 创建了问题 11月24日

悬赏问题

  • ¥15 mmo能不能做客户端怪物
  • ¥15 osm下载到arcgis出错
  • ¥15 Dell g15 每次打开eiq portal后3分钟内自动退出
  • ¥200 使用python编写程序,采用socket方式获取网页实时刷新的数据,能定时print()出来就行。
  • ¥15 matlab如何根据图片中的公式绘制e和v的曲线图
  • ¥15 我想用Python(Django)+Vue搭建一个用户登录界面,但是在运行npm run serve时报错了如何解决?
  • ¥15 QQ邮箱过期怎么恢复?
  • ¥15 登录他人的vue项目显示服务器错误
  • ¥15 (标签-android|关键词-app)
  • ¥15 comsol仿真压阻传感器