You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "raghutpk (Closed) (JIRA)" <ji...@apache.org> on 2012/02/08 07:10:59 UTC

[jira] [Closed] (CONFIGURATION-479) Cannot write to files within an app server directory

     [ https://issues.apache.org/jira/browse/CONFIGURATION-479?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

raghutpk closed CONFIGURATION-479.
----------------------------------

    Resolution: Duplicate
    
> Cannot write to files within an app server directory
> ----------------------------------------------------
>
>                 Key: CONFIGURATION-479
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-479
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: Build
>    Affects Versions: 1.7, 1.8
>         Environment: Java , Linux, Jboss
>            Reporter: raghutpk
>              Labels: commons, configuration
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> Hi 
> This issue is really grappling me. I use  Apache commons configuration to read the configuration for my application. I expose my configuration through a jmx client so that I can change the configuration at runtime and would like to persist the changes to the original load form.
> I have multiple configuration sources so I use a CombinedConfiguration object to read in my config.xml file. I have wrapped custom logic and rules to save the confgiuration to the persistent store.
> I use Jboss AS5 to deploy my application. 
> All is well when I have configuration files in the filesystem outside  $JBOSS-HOME/server/default/deploy. I am able to read fine and write back to the config files fine too. 
> but the problem is when I bring in the Config files in the following directoy $JBOSS-HOME/server/default/deploy/{application-name}/..
> I can read the configuration fine, but when I try to write the configuration back to the persistent store using the save method of the respective configuration(like PropertiesConfiguration & XMLConfiguration) using a jmx client(I also tried to harcode and save within code immediatly after reading my configuration). I keep getting the follwing exception :
> java.net.UnknownServiceException: protocol doesn't support output
> 	at java.net.URLConnection.getOutputStream(URLConnection.java:792)
> 	at org.apache.commons.configuration.DefaultFileSystem.getOutputStream(DefaultFileSystem.java:113)
> 	at org.apache.commons.configuration.AbstractFileConfiguration.save(AbstractFileConfiguration.java:461)
> 	at org.apache.commons.configuration.AbstractFileConfiguration.save(AbstractFileConfiguration.java:402)
> 	at org.apache.commons.configuration.AbstractFileConfiguration.possiblySave(AbstractFileConfiguration.java:737)
> 	at org.apache.commons.configuration.AbstractFileConfiguration.clearProperty(AbstractFileConfiguration.java:784)
> 	at org.apache.commons.configuration.AbstractConfiguration.setProperty(AbstractConfiguration.java:483)
> 	at org.apache.commons.configuration.AbstractFileConfiguration.setProperty(AbstractFileConfiguration.java:774)
>         ......
> Please throw some light on the exception because it is helping me nowhere in understanding the issue
> If I am able to read it, I should also be able to save it back..but it is not happening within JBOSS directory(I can only read). Moment I shift my configurations outside that to a different place in the Filesystem say /home/../Config and also keep the config.xml(containing the reference to the Configuration sources)it is perfectly working fine.
> This is being a blocker for me. I may have completely misread the scenario, so please throw light on the same if I am missing anything or more details are needed.
> Following is the piece of code used to read the configuration :
> ...
> builder.setFile(new File(Path to CONFIG_DIRECTORY +
> 		  CONFIG_DEFINITION_FILENAME(config.xml)));
> CombinedConfiguration combinedConfig = builder.getConfiguration(true); 
> sample config.xml file : 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <configuration>
> 	<header />
> 	<override>
> 		<properties
> 			fileName="db.properties"
> 			autoSave="true" config-name="properties1" />
> 	<properties
> 			fileName="jms.properties"
> 			autoSave="true" config-name="properties2" />
> 		<properties
> 			fileName="test.xml"
> 			autoSave="true" config-name="properties3" />
> 		<xml fileName="gui.xml"
> 			autoSave="true" config-name="xml1" />
> 	</override>
> 	<additional />
> </configuration>
> Following is sample code used to write back updated values to the persistent store :
> 	xmlConfig = (XMLConfiguration) combinedConfig.getConfiguration("configuration source name");;
> 							if (xmlConfig.containsKey(key)) {
> 								try {
> 									// Update the value.
> 									xmlConfig.setProperty(key, value);
> 									xmlConfig.save();

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira