apache / servicecomb-java-chassis

ServiceComb Java Chassis is a Software Development Kit (SDK) for rapid development of microservices in Java, providing service registration, service discovery, dynamic routing, and service management features
Apache License 2.0
1.91k stars 813 forks source link

servicecomb解析环境变量异常参数失败,导致无法启动 #2178

Closed neverstop closed 3 years ago

neverstop commented 3 years ago

使用版本 servicecomb 2.0.2

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.servicecomb.core.ConfigurationSpringInitializer#0' defined in URL [jar:file:/opt/huawei/release/speaker/SCSpeakerKgService/20201230013554/lib/java-chassis-core-2.0.2.jar!/META-INF/spring/cse.bean.xml]: Initialization of bean failed; nested exception is java.lang.RuntimeException: set up spring property source failed.If you still want to start up the application and ignore errors, you can set servicecomb.config.ignoreResolveFailure to true. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:155) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:707) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:144) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:95) at org.apache.servicecomb.foundation.common.utils.BeanUtils.init(BeanUtils.java:62) at org.apache.servicecomb.foundation.common.utils.BeanUtils.init(BeanUtils.java:53) at com.huawei.poisson.knowledgegraph.SpeakerKnowledgeGraphMain.main(SpeakerKnowledgeGraphMain.java:62) Caused by: java.lang.RuntimeException: set up spring property source failed.If you still want to start up the application and ignore errors, you can set servicecomb.config.ignoreResolveFailure to true. at org.apache.servicecomb.core.ConfigurationSpringInitializer.getProperties(ConfigurationSpringInitializer.java:207) at org.apache.servicecomb.core.ConfigurationSpringInitializer.getAllProperties(ConfigurationSpringInitializer.java:182) at org.apache.servicecomb.core.ConfigurationSpringInitializer.setEnvironment(ConfigurationSpringInitializer.java:83) at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:108) at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:100) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:415) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1786) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ... 13 more Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'IFS+x' in value "() { unset _mlre _mlIFS _mlshdbg; if [ "${MODULES_SILENT_SHELL_DEBUG:-0}" = '1' ]; then case "$-" in vx) set +vx; _mlshdbg='vx' ;; v) set +v; _mlshdbg='v' ;; x) set +x; _mlshdbg='x' ;; ) _mlshdbg='' ;; esac; fi; if [ -n "${IFS+x}" ]; then _mlIFS=$IFS; fi; IFS=' '; for _mlv in ${MODULES_RUN_QUARANTINE:-}; do if [ "${_mlv}" = "${mlv##*[!A-Za-z0-9]}" -a "${_mlv}" = "${_mlv#[0-9]}" ]; then

yhs0092 commented 3 years ago

Caused by: java.lang.RuntimeException: set up spring property source failed.If you still want to start up the application and ignore errors, you can set servicecomb.config.ignoreResolveFailure to true. 解决方法已经在日志里面打出来了,microservice.yaml文件配置一下servicecomb.config.ignoreResolveFailure=true就能解决

yhs0092 commented 3 years ago

这种通常是部署环境的环境变量里有些很复杂的内容,Java-Chassis使用Spring做配置的加载和解析的时候碰到花括号,误将其作为配置占位符进行解析而报错导致的。

neverstop commented 3 years ago

我们机器部署了四台 两台ok 两台不行。 我想知道为什么不行 不然现网没办法手动改配置

yhs0092 commented 3 years ago

两台行的是x86的,两台不行的是arm的吗?直接原因刚刚已经给出来了,建议先排查一下环境变量吧 : )

neverstop commented 3 years ago

是的 不行的arm的。 但是arm也有成功的 我已经在排查环境变量了

neverstop commented 3 years ago

的确发现了奇怪的环境变量 我们会加载所有的环境变量对吗 有奇怪的就会报错是吗

yhs0092 commented 3 years ago

的确发现了奇怪的环境变量 我们会加载所有的环境变量对吗 有奇怪的就会报错是吗

是的,Java-Chassis又不知道哪些是你想要的,所以只能全部加载了

neverstop commented 3 years ago

好的 了解了 多谢