在JBoss中读取/写入.properties文件会导致异常

时间:2017-11-09 23:54:27

标签: java jboss apache-commons

目前我正在开发一个基于Web的应用程序,该应用程序将部署在各种java Web应用程序容器中。我写入读/写.properties文件的代码是使用apache commons,代码可以在下面看到;

FileBasedConfigurationBuilder<PropertiesConfiguration> builder = configs.propertiesBuilder(PATH_TO_PROPERTIES);
..update some properties

builder.save();

不幸的是,抛出一个异常,说我无法写入vfs:/ ......我假设Apache Commons没有处理vfs,有没有人遇到过这个?如何通常解决支持多种类型的应用程序服务器?

18:51:31,317 ERROR [com.company.pkg.PropertiesUtil] (default task-31) Unable to update properties: org.apache.commons.configuration2.ex.ConfigurationException: Could not save to URL vfs:/content/MyApplication.war/WEB-INF/classes/config.properties
at org.apache.commons.configuration2.io.DefaultFileSystem.getOutputStream(DefaultFileSystem.java:97)
at org.apache.commons.configuration2.io.FileHandler.save(FileHandler.java:1214)
at org.apache.commons.configuration2.io.FileHandler.save(FileHandler.java:1163)
at org.apache.commons.configuration2.io.FileHandler.save(FileHandler.java:805)
at org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder.save(FileBasedConfigurationBuilder.java:240)
.....
Caused by: java.net.UnknownServiceException: protocol doesn't support output
at java.net.URLConnection.getOutputStream(URLConnection.java:843)
at org.apache.commons.configuration2.io.DefaultFileSystem.getOutputStream(DefaultFileSystem.java:86)
... 94 more

0 个答案:

没有答案