首页 新闻 搜索 专区 学院

java web程序,在修改properties文件后,应用会重启服务

0
悬赏园豆:50 [待解决问题]
报错功能描述:
  将token_id的值更新到class下bppm.properties(普通文件)文件中。
系统在执行完如下代码后会重启,Java代码如下:
Properties prop = new Properties();
try {
  String realPathSRC = PropertiesUtil.class.getClassLoader().getResource("/").getPath();
  //判断文件是否存在,如果存在将属性及值取得放到Properties,关闭文件流
  File file = new File(realPathSRC + "bppm.properties");
  if (!file.exists())
    file.createNewFile();
  InputStream fis = new FileInputStream(file);
  prop.load(fis);
  fis.close();// 一定要在修改值之前关闭fis
  OutputStream fos = new FileOutputStream(PropertiesUtil.class.getClassLoader().getResource(PROPERTY_FILE).getPath());
  prop.setProperty("TOKEN_ID", "tokenID");
  prop.store(fos, "");
  fos.close();
  } catch (Exception e) {            
    e.printStackTrace();
  }
 
代码中红色部分代码注释掉后,系统运行正常不报错,不重启。
宕机报错信息:
一月 11, 2016 6:47:01 下午 org.apache.catalina.core.ApplicationContext log
信息: Shutting down log4j
一月 11, 2016 6:47:01 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/nump_data_rest] appears to have started a thread named [FileWatchdog] but has failed to stop it. This is very likely to create a memory leak.
一月 11, 2016 6:47:01 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/nump_data_rest] appears to have started a thread named [Thread-2] but has failed to stop it. This is very likely to create a memory leak.
一月 11, 2016 6:47:01 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/nump_data_rest] appears to have started a thread named [tmqiConnectionFlowControl-0] but has failed to stop it. This is very likely to create a memory leak.
一月 11, 2016 6:47:01 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/nump_data_rest] appears to have started a thread named [iMQReadChannel-0] but has failed to stop it. This is very likely to create a memory leak.
一月 11, 2016 6:47:01 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/nump_data_rest] appears to have started a thread named [tmqiConsumerReader-0-646-0] but has failed to stop it. This is very likely to create a memory leak.
log4j:WARN No appenders could be found for logger (org.apache.http.impl.conn.PoolingHttpClientConnectionManager).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

 

 
不畏将来,不念过往的主页 不畏将来,不念过往 | 初学一级 | 园豆:156
提问于:2016-01-12 10:36
< >
分享
所有回答(1)
0

你 好我也遇到了相同的问题,修改properties 后,tomcat 直接就挂掉了 自动重起,调式进去,也没有看出为什么会这样。

love椰子菇凉 | 园豆:202 (菜鸟二级) | 2017-12-13 14:07
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册