dubbo springboot ,IllegalStateException: ApplicationConfig.application == null

400.100、异常环境

dubbo-spring-boot-starter:0.2.0
spring-boot-starters:2.0.3.RELEASE
JDK 8

400.200、异常详情:

console- 2018-08-10 09:55:12.222 [ERROR] [main]  org.springframework.boot.SpringApplication[SpringApplication.java:842] - Application run failed
java.lang.IllegalStateException: ApplicationConfig.application == null
	at com.alibaba.dubbo.config.AbstractConfig.appendParameters(AbstractConfig.java:246)
	at com.alibaba.dubbo.config.AbstractConfig.appendParameters(AbstractConfig.java:181)
	at com.alibaba.dubbo.config.AbstractInterfaceConfig.loadRegistries(AbstractInterfaceConfig.java:175)
	at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:356)
	at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:317)
	at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:216)
	at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:123)
	at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:49)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:400)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:354)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:888)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:161)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)
	at com.xxx.xx.xxxBusServerApplication.main(IxxBusServerApplication.java:34)
Caused by: java.lang.IllegalStateException: ApplicationConfig.application == null
	at com.alibaba.dubbo.config.AbstractConfig.appendParameters(AbstractConfig.java:231)
	... 22 common frames omitted

400.300、异常原因

dubbo配置:

│        dubbo.application.name = ${spring.profiles.active}-bus-service
│        dubbo.protocol.id = dubbo
│        dubbo.protocol.name = dubbo
│        dubbo.protocol.port = 20886
│        dubbo.protocol.register = true
│        dubbo.registry.address =
│        dubbo.registry.group = smsroot_${spring.profiles.active}
│        dubbo.registry.id = ${spring.profiles.active}-registry

----------------------------------------------------------------------------------------------------

由于dubbo配置使用了变量,导致正则不能通过校验。

checkProperty:405, AbstractConfig {com.alibaba.dubbo.config}

              |-- application.name不符合正则[\-._0-9a-zA-Z]+,抛出异常

                             |-- bind:79, JavaBeanBinder {org.springframework.boot.context.properties.bind} 继续抛出异常

                                         |-- withIncreasedDepth:444, Binder$Context (org.springframework.boot.context.properties.bind) 没有catch异常(忽略了),直接finally。所以最后AbstractConfig 没有被正确初始化

checkName:362, AbstractConfig {com.alibaba.dubbo.config}
setName:96, ApplicationConfig {com.alibaba.dubbo.config}

400.400、解决异常

dubbo的配置都使用常量

 

 

你可能感兴趣的:(问题和异常)