disconf配置文件获取失败

启动程序报错:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springPropertyConfigurer' defined in URL [jar:file:/home/fightfaith/develop/tomcat/webapps/cc-manage-web/WEB-INF/lib/cc-manage-resource-0.0.1.jar!/applicationContext.xml]: Cannot resolve reference to bean 'configproperties_no_reloadable_disconf' while setting bean property 'propertiesArray' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configproperties_no_reloadable_disconf' defined in URL [jar:file:/home/fightfaith/develop/tomcat/webapps/cc-manage-web/WEB-INF/lib/cc-manage-resource-0.0.1.jar!/applicationContext.xml]: Invocation of init method failed; nested exception is java.io.FileNotFoundException: class path resource [manage_static.properties] cannot be opened because it does not exist
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:382)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:157)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1531)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1276)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:149)
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configproperties_no_reloadable_disconf' defined in URL [jar:file:/home/fightfaith/develop/tomcat/webapps/cc-manage-web/WEB-INF/lib/cc-manage-resource-0.0.1.jar!/applicationContext.xml]: Invocation of init method failed; nested exception is java.io.FileNotFoundException: class path resource [manage_static.properties] cannot be opened because it does not exist
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
	... 26 more
Caused by: java.io.FileNotFoundException: class path resource [manage_static.properties] cannot be opened because it does not exist
	at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
	at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:154)
	at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:98)
	at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:175)
	at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:156)
	at com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean.doReload(ReloadablePropertiesFactoryBean.java:228)
	at com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean.reload(ReloadablePropertiesFactoryBean.java:218)
	at com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean.createMyInstance(ReloadablePropertiesFactoryBean.java:169)
	at com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean.createProperties(ReloadablePropertiesFactoryBean.java:148)
	at org.springframework.beans.factory.config.PropertiesFactoryBean.afterPropertiesSet(PropertiesFactoryBean.java:71)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
	... 33 more

之前有一次是因为disconf的配置文件要下载并写入到本地, 然后对要写入的文件夹没有写入权限导致, 这次首先查看了一下tomcat配置:
disconf配置文件获取失败

目录...../cc-manage是肯定有写入权限的, 所以不是写入权限的问题.

访问disconf:
disconf配置文件获取失败
发现是502网关错误, 找到disconf的nginx配置:
    server {
        listen   80;
        server_name disconf.***.net;
        access_log /server/logs/disconf.***.net-access.log;
        error_log /server/logs/disconf.***.net-error.log;
        location / {
            root /home/***/disconf/war/html;
            if ($query_string) {
                expires max;
            }
        }
        location ~ ^/(api|export) {
            allow 182.50.***.103;
            allow 114.242.***.86;
            allow 192.168.0.1;
            #deny all;
            proxy_pass_header Server;
            proxy_set_header Host $http_host;
            proxy_redirect off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Scheme $scheme;
            proxy_pass http://192.168.0.49:8080;
        }
    }

查看disconf错误日志:
2018/08/01 11:10:13 [error] 21087#21087: *3441 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.253, server: disconf.btzh.net, request: "GET /api/config/file?version=1_0_0_0&app=cc-manage-web&env=online&key=manage_static.properties&type=0 HTTP/1.1", upstream: "http://192.168.0.49:8080/api/config/file?version=1_0_0_0&app=cc-manage-web&env=online&key=manage_static.properties&type=0", host: "disconf.btzh.net"
2018/08/01 11:11:25 [error] 21087#21087: *3464 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.253, server: disconf.btzh.net, request: "GET /api/account/session HTTP/1.1", upstream: "http://192.168.0.49:8080/api/account/session", host: "disconf.btzh.net", referrer: "http://disconf.btzh.net/"
2018/08/01 11:11:42 [error] 21087#21087: *3469 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.253, server: disconf.btzh.net, request: "GET /api/account/session HTTP/1.1", upstream: "http://192.168.0.49:8080/api/account/session", host: "disconf.btzh.net", referrer: "http://disconf.btzh.net/login.html"
vi2018/08/01 11:32:18 [error] 21086#21086: *3862 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.253, server: disconf.btzh.net, request: "GET /api/account/session HTTP/1.1", upstream: "http://192.168.0.49:8080/api/account/session", host: "disconf.btzh.net", referrer: "http://disconf.btzh.net/main.html"
2018/08/01 11:32:18 [error] 21086#21086: *3863 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.253, server: disconf.btzh.net, request: "GET /api/app/list HTTP/1.1", upstream: "http://192.168.0.49:8080/api/app/list", host: "disconf.btzh.net", referrer: "http://disconf.btzh.net/main.html"
2018/08/01 11:32:18 [error] 21086#21086: *3862 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.253, server: disconf.btzh.net, request: "GET /api/env/list HTTP/1.1", upstream: "http://192.168.0.49:8080/api/env/list", host: "disconf.btzh.net", referrer: "http://disconf.btzh.net/main.html"
2018/08/01 11:32:18 [error] 21086#21086: *3860 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.253, server: disconf.btzh.net, request: "GET /api/account/session HTTP/1.1", upstream: "http://192.168.0.49:8080/api/account/session", host: "disconf.btzh.net", referrer: "http://disconf.btzh.net/login.html"
2018/08/01 11:34:00 [error] 21086#21086: *3894 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.253, server: disconf.btzh.net, request: "GET /api/zoo/hosts HTTP/1.1", upstream: "http://192.168.0.49:8080/api/zoo/hosts", host: "disconf.btzh.net"
2018/08/01 11:34:02 [error] 21086#21086: *3896 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.253, server: disconf.btzh.net, request: "GET /api/config/file?version=1_0_0_0&app=cc-manage-web&env=online&key=manage_config.properties&type=0 HTTP/1.1", upstream: "http://192.168.0.49:8080/api/config/file?version=1_0_0_0&app=cc-manage-web&env=online&key=manage_config.properties&type=0", host: "disconf.btzh.net"
2018/08/01 11:34:04 [error] 21086#21086: *3899 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.253, server: disconf.btzh.net, request: "GET /api/config/file?version=1_0_0_0&app=cc-manage-web&env=online&key=manage_static.properties&type=0 HTTP/1.1", upstream: "http://192.168.0.49:8080/api/config/file?version=1_0_0_0&app=cc-manage-web&env=online&key=manage_static.properties&type=0", host: "disconf.btzh.net"
2018/08/01 11:34:09 [error] 21086#21086: *3903 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.253, server: disconf.btzh.net, request: "GET /api/zoo/hosts HTTP/1.1", upstream: "http://192.168.0.49:8080/api/zoo/hosts", host: "disconf.btzh.net"
2018/08/01 11:34:11 [error] 21086#21086: *3905 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.253, server: disconf.btzh.net, request: "GET /api/config/file?version=1_0_0_0&app=cc-manage-web&env=online&key=manage_config.properties&type=0 HTTP/1.1", upstream: "http://192.168.0.49:8080/api/config/file?version=1_0_0_0&app=cc-manage-web&env=online&key=manage_config.properties&type=0", host: "disconf.btzh.net"
2018/08/01 11:34:13 [error] 21086#21086: *3907 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.253, server: disconf.btzh.net, request: "GET /api/config/file?version=1_0_0_0&app=cc-manage-web&env=online&key=manage_static.properties&type=0 HTTP/1.1", upstream: "http://192.168.0.49:8080/api/config/file?version=1_0_0_0&app=cc-manage-web&env=online&key=manage_static.properties&type=0", host: "disconf.btzh.net"

日志提到访问49机器端口8080/api/接口失败, 到49机器:
root@mach9:/server/logs# ps -ef|grep tomcat
root      7213  2033  0 11:38 pts/0    00:00:00 grep --color=auto tomcat

怀疑tomcat进程死掉的原因, 启动tomcat:
root@mach9:/usr/local/apache-tomcat-8.0.35/bin# ./startup.sh 
Using CATALINA_BASE:   /usr/local/apache-tomcat-8.0.35
Using CATALINA_HOME:   /usr/local/apache-tomcat-8.0.35
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.0.35/temp
Using JRE_HOME:        /usr/local/jdk1.8.0_91
Using CLASSPATH:       /usr/local/apache-tomcat-8.0.35/bin/bootstrap.jar:/usr/local/apache-tomcat-8.0.35/bin/tomcat-juli.jar
Tomcat started.

disconf访问成功, 项目启动成功.
上一篇:javascript中的错误处理机制


下一篇:Git.Framework 框架随手记--ORM编辑删除