maven整合zookeeper时提示Error creating bean with name ‘XXX‘ defined in file....;cause: Zookeeper is not..

博客内容讲述了在Spring Boot应用中使用Dubbo时遇到的一个常见错误,即尝试注册服务到Zookeeper时由于Zookeeper未连接导致的Bean创建异常。错误堆栈显示了从`ContextLoaderListener`初始化上下文时触发的问题,进一步指出可能原因是Linux防火墙未关闭。解决方案提到检查并管理Linux系统的firewalld服务状态,包括启动、停止、查询开机启动设置等操作。

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:\JavaProject\Dubbo\dubbodemo-provider\target\classes\com\hmf\service\impl\HelloServiceImpl.class]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Failed to register dubbo://192.168.137.1:20881/com.hmf.service.HelloService?anyhost=true&application=dubbodemo-provider&dubbo=2.6.0&generic=false&interface=com.hmf.service.HelloService&methods=sayHello&pid=14220&side=provider&timestamp=1649216174846 to registry 192.168.113.128:2181, cause: Failed to register dubbo://192.168.137.1:20881/com.hmf.service.HelloService?anyhost=true&application=dubbodemo-provider&dubbo=2.6.0&generic=false&interface=com.hmf.service.HelloService&methods=sayHello&pid=14220&side=provider&timestamp=1649216174846 to zookeeper zookeeper://192.168.113.128:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbodemo-provider&dubbo=2.6.0&interface=com.alibaba.dubbo.registry.RegistryService&pid=14220&timestamp=1649216174838, 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$doGetBean0(AbstractBeanFactory.java:317)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)atorg.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:409)atorg.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291)atorg.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)atorg.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)atorg.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)atorg.apache.catalina.core.ContainerBase0(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.ContainerBase0(AbstractBeanFactory.java:317)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)atorg.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:409)atorg.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291)atorg.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)atorg.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)atorg.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)atorg.apache.catalina.core.ContainerBaseStartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBaseStartChild.call(ContainerBase.java:1549)atjava.util.concurrent.FutureTask.run(FutureTask.java:266)atjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)atjava.util.concurrent.ThreadPoolExecutorStartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutorStartChild.call(ContainerBase.java:1549)atjava.util.concurrent.FutureTask.run(FutureTask.java:266)atjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)atjava.util.concurrent.ThreadPoolExecutorWorker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

解决方案:Linux的防火墙可能没有关闭
查看防火墙状态: systemctl status firewalld
启动防火墙: systemctl start firewalld
关闭防火墙: systemctl stop firewalld
查询防火墙服务是否开机启动: systemctl is-enabled firewalld
开机时启用防火墙服务: systemctl enable firewalld
开机时禁用防火墙服务: systemctl disable firewalld

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值