0 Replies Latest reply on Nov 9, 2017 6:53 PM by dholmblad

    Reading/Writing .properties file in JBoss causes exceptions

    dholmblad

      Currently I am developing a web based application which will be deployed on a variety of java web application containers. The code Ive written to read/write .properties files is using apache commons, the code can be seen below;

       

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

       

      Unfortunately an exception is thrown stating that I was unable to write to vfs:/...... I assume the Apache Commons is not handling vfs, has anyone encountered this before? How can it be commonly resolved to support multiple types of application servers?

       

       

       

      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