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

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日

悬赏问题

  • ¥20 机器学习或深度学习问题?困扰了我一个世纪,晚来天欲雪,能饮一杯无?
  • ¥15 c语言数据结构高铁订票系统
  • ¥15 关于wkernell.PDB加载的问题,如何解决?(语言-c#|开发工具-vscode)
  • ¥15 (标签-STM32|关键词-智能小车)
  • ¥20 关于#stm32#的问题,请各位专家解答!
  • ¥15 (标签-python)
  • ¥20 搭建awx,试了很多版本都有错
  • ¥15 java corba的客户端该如何指定使用本地某个固定IP去连接服务端?
  • ¥15 activiti工作流问题,求解答
  • ¥15 有人写过RPA后台管理系统么?