No application config found or it‘s not a valid config! Please add <dubbo:application name=“...“ />

本文涉及的产品
服务治理 MSE Sentinel/OpenSergo,Agent数量 不受限
注册配置 MSE Nacos/ZooKeeper,118元/月
云原生网关 MSE Higress,422元/月
简介: No application config found or it‘s not a valid config! Please add <dubbo:application name=“...“ />

首先我的项目结构是这样的:

作为一个简单的Demo项目,启动时报错:

No application config found or it’s not a valid config! Please add <dubbo:application name=“…” />

可是配置添加了

application.properties
```java
# 服务器端口号设为8082
server.port=8082
# 应用程序名称设为actuator
spring.application.name=actuator
# Dubbo注册中心地址
dubbo.registry.address=zookeeper://192.168.122.128:2181
# Dubbo协议名称
dubbo.protocol.name=dubbo
# Dubbo协议端口号
dubbo.protocol.port=-1
# Dubbo注册中心连接超时时间
dubbo.registry.timeout=60000
# Dubbo服务消费者重试次数
dubbo.consumer.retries=3
# Dubbo应用程序QoS(Quality of Service)开启
dubbo.application.qos.enable=true
# Dubbo QoS(Quality of Service)协议端口号
dubbo.qos.port=22222

通过搜索引擎尝试:原来项目的dubbo版本是3.0.0,修改为以下

1.jdk1.8+dubbo版本是2.7.5版本是没有问题
2.jdk11+dubbo版本是2.7.1版本是没有问题的

然后报错:

Description:
The bean 'dubboBootstrapApplicationListener' could not be registered. A bean with that name has already been defined and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

添加配置:spring.main.allow-bean-definition-overriding=true,启动类上添加注解@EnableDubbo

然后报错:

java.lang.IllegalStateException: zookeeper not connected
  at org.apache.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.<init>(CuratorZookeeperClient.java:83) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.remoting.zookeeper.curator.CuratorZookeeperTransporter.createZookeeperClient(CuratorZookeeperTransporter.java:26) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.remoting.zookeeper.support.AbstractZookeeperTransporter.connect(AbstractZookeeperTransporter.java:68) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter$Adaptive.connect(ZookeeperTransporter$Adaptive.java) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.configcenter.support.zookeeper.ZookeeperDynamicConfiguration.<init>(ZookeeperDynamicConfiguration.java:70) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.configcenter.support.zookeeper.ZookeeperDynamicConfigurationFactory.createDynamicConfiguration(ZookeeperDynamicConfigurationFactory.java:37) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.common.config.configcenter.AbstractDynamicConfigurationFactory.lambda$getDynamicConfiguration$0(AbstractDynamicConfigurationFactory.java:39) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.common.config.configcenter.AbstractDynamicConfigurationFactory$$Lambda$565/918738473.apply(Unknown Source) ~[na:na]
  at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) ~[na:1.8.0_51]
  at org.apache.dubbo.common.config.configcenter.AbstractDynamicConfigurationFactory.getDynamicConfiguration(AbstractDynamicConfigurationFactory.java:39) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.common.config.configcenter.DynamicConfiguration.getDynamicConfiguration(DynamicConfiguration.java:223) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.config.bootstrap.DubboBootstrap.prepareEnvironment(DubboBootstrap.java:815) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.config.bootstrap.DubboBootstrap.startConfigCenter(DubboBootstrap.java:560) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.config.bootstrap.DubboBootstrap.useRegistryAsConfigCenterIfNecessary(DubboBootstrap.java:624) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.config.bootstrap.DubboBootstrap.initialize(DubboBootstrap.java:508) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:698) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextRefreshedEvent(DubboBootstrapApplicationListener.java:52) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:45) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.config.spring.context.OneTimeExecutionApplicationContextEventListener.onApplicationEvent(OneTimeExecutionApplicationContextEventListener.java:40) ~[dubbo-2.7.5.jar:2.7.5]
  at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:898) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:755) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:402) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1247) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1236) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at com.example.dubboactuator.DubboActuatorApplication.main(DubboActuatorApplication.java:16) [classes/:na]
Caused by: java.lang.IllegalStateException: zookeeper not connected
  at org.apache.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.<init>(CuratorZookeeperClient.java:80) ~[dubbo-2.7.5.jar:2.7.5]
  ... 33 common frames omitted
2023-07-28 22:19:03.204  WARN 15832 --- [           main] ConfigServletWebServerApplicationContext : Exception thrown from ApplicationListener handling ContextClosedEvent
java.lang.NullPointerException: null
  at org.apache.dubbo.config.bootstrap.DubboBootstrap.unexportMetadataService(DubboBootstrap.java:857) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.config.bootstrap.DubboBootstrap.destroy(DubboBootstrap.java:996) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.config.bootstrap.DubboBootstrap.stop(DubboBootstrap.java:776) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextClosedEvent(DubboBootstrapApplicationListener.java:56) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:47) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.config.spring.context.OneTimeExecutionApplicationContextEventListener.onApplicationEvent(OneTimeExecutionApplicationContextEventListener.java:40) ~[dubbo-2.7.5.jar:2.7.5]
  at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404) [spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361) [spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1013) [spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.doClose(ServletWebServerApplicationContext.java:170) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:979) [spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:811) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1247) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1236) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at com.example.dubboactuator.DubboActuatorApplication.main(DubboActuatorApplication.java:16) [classes/:na]
2023-07-28 22:19:03.205  INFO 15832 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
2023-07-28 22:19:03.205  INFO 15832 --- [           main] f.a.ReferenceAnnotationBeanPostProcessor : class org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor was destroying!
Disconnected from the target VM, address: '127.0.0.1:53183', transport: 'socket'
Process finished with exit code 1

通过另一个项目测试zookeeper可以正常访问,说明不是zookeeper的问题,那么还是回归到代码本身,推测要么是配置不对,要么是版本有冲突或者不支持。而根据后续日志分析:

java.lang.NullPointerException: null
  at org.apache.dubbo.config.bootstrap.DubboBootstrap.unexportMetadataService(DubboBootstrap.java:857) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.config.bootstrap.DubboBootstrap.destroy(DubboBootstrap.java:996) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.config.bootstrap.DubboBootstrap.stop(DubboBootstrap.java:776) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextClosedEvent(DubboBootstrapApplicationListener.java:56) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:47) ~[dubbo-2.7.5.jar:2.7.5]
  at org.apache.dubbo.config.spring.context.OneTimeExecutionApplicationContextEventListener.onApplicationEvent(OneTimeExecutionApplicationContextEventListener.java:40) ~[dubbo-2.7.5.jar:2.7.5]

有一个对null对象的引用,而不应该有null对象,特别是在“DubboBootstrap”类中,当取消扩展元数据服务时。可以看到unexportMetadataService()方法中存在空指针异常,可能是由于元数据服务未正确导出或其他原因导致的。这可能是由应用程序中的编码错误或Dubbo框架的配置问题引起的。

尝试使用Dubbo 2.7.6,因为从Dubbo 2.7.6开始,有关元数据服务的处理已经得到了改进。

然后又报错:

java.lang.IllegalStateException: Invalid name="org.apache.dubbo.config.ApplicationConfig#0" contains illegal character, only digit, letter, '-', '_' or '.' is legal.
  at org.apache.dubbo.config.utils.ConfigValidationUtils.checkProperty(ConfigValidationUtils.java:588) ~[dubbo-2.7.6.jar:2.7.6]
  at org.apache.dubbo.config.utils.ConfigValidationUtils.checkName(ConfigValidationUtils.java:546) ~[dubbo-2.7.6.jar:2.7.6]
  at org.apache.dubbo.config.utils.ConfigValidationUtils.validateApplicationConfig(ConfigValidationUtils.java:386) ~[dubbo-2.7.6.jar:2.7.6]
  at org.apache.dubbo.config.bootstrap.DubboBootstrap.checkGlobalConfigs(DubboBootstrap.java:526) ~[dubbo-2.7.6.jar:2.7.6]
  at org.apache.dubbo.config.bootstrap.DubboBootstrap.initialize(DubboBootstrap.java:513) ~[dubbo-2.7.6.jar:2.7.6]
  at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:740) ~[dubbo-2.7.6.jar:2.7.6]
  at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextRefreshedEvent(DubboBootstrapApplicationListener.java:59) ~[dubbo-2.7.6.jar:2.7.6]
  at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:52) ~[dubbo-2.7.6.jar:2.7.6]
  at org.apache.dubbo.config.spring.context.OneTimeExecutionApplicationContextEventListener.onApplicationEvent(OneTimeExecutionApplicationContextEventListener.java:40) ~[dubbo-2.7.6.jar:2.7.6]
  at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:898) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
  at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:755) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:402) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1247) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1236) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
  at com.example.dubboactuator.DubboActuatorApplication.main(DubboActuatorApplication.java:16) [classes/:na]
2023-07-28 22:48:25.086  INFO 18636 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
2023-07-28 22:48:25.086  INFO 18636 --- [           main] f.a.ReferenceAnnotationBeanPostProcessor : class org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor was destroying!
Disconnected from the target VM, address: '127.0.0.1:54870', transport: 'socket'
Process finished with exit code 1

添加配置:

dubbo.application.name=actuator

启动就不报错了


相关实践学习
基于MSE实现微服务的全链路灰度
通过本场景的实验操作,您将了解并实现在线业务的微服务全链路灰度能力。
相关文章
|
6月前
|
XML 监控 Dubbo
从初学者到专家:Dubbo中Application的终极指南【十一】
从初学者到专家:Dubbo中Application的终极指南【十一】
110 0
IDEA添加Swagger2:Parameter 0 of method linkDiscoverers in org. springframework hateoas.config.Hateoasconfiguration required a single bean, but 15 were found:
IDEA添加Swagger2:Parameter 0 of method linkDiscoverers in org. springframework hateoas.config.Hateoasconfiguration required a single bean, but 15 were found
|
5月前
|
开发工具 git
*** Please tell me who you are.Run git config --global user.email “you@example.com“ git confi
*** Please tell me who you are.Run git config --global user.email “you@example.com“ git confi
|
6月前
|
关系型数据库 Serverless 分布式数据库
Serverless 应用引擎常见问题之安装完serverless dev通过终端执行s config add返回错误如何解决
Serverless 应用引擎(Serverless Application Engine, SAE)是一种完全托管的应用平台,它允许开发者无需管理服务器即可构建和部署应用。以下是Serverless 应用引擎使用过程中的一些常见问题及其答案的汇总:
|
6月前
|
关系型数据库 MySQL 数据库
Mysql-错误处理: Found option without preceding group in config file
Mysql-错误处理: Found option without preceding group in config file
754 0
|
6月前
|
Dubbo 应用服务中间件
【Default config not found for ApplicationConfig】的一种解决方案
【Default config not found for ApplicationConfig】的一种解决方案
678 0
|
关系型数据库 MySQL Linux
DVWA CentOS Could not connect to the MySQL service. Please check the config file.
DVWA CentOS Could not connect to the MySQL service. Please check the config file.
66 0
|
缓存 Dubbo Java
Dubbo配置注册中心设置application的name使用驼峰命名法可能存在的隐藏启动异常问题
Dubbo配置注册中心设置application的name使用驼峰命名法可能存在的隐藏启动异常问题
80 0
|
Java
解决:Config service failed to start in 120 seconds! Please check ./service/apollo-service.log...
解决:Config service failed to start in 120 seconds! Please check ./service/apollo-service.log...
155 0
|
2月前
|
算法 安全 Java
微服务(四)-config配置中心的配置加解密
微服务(四)-config配置中心的配置加解密