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 (Created) (JIRA)" <ji...@apache.org> on 2012/02/08 06:12:59 UTC

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

Cannot write to files within an app server directory
----------------------------------------------------

                 Key: CONFIGURATION-478
                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-478
             Project: Commons Configuration
          Issue Type: Bug
          Components: Build
    Affects Versions: 1.8, 1.7
         Environment: Java , Linux, Jboss
            Reporter: raghutpk


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

        

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

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CONFIGURATION-478?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oliver Heger resolved CONFIGURATION-478.
----------------------------------------

       Resolution: Invalid
    Fix Version/s: 1.9

Got no more feedback, so closing as invalid.
                
> Cannot write to files within an app server directory
> ----------------------------------------------------
>
>                 Key: CONFIGURATION-478
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-478
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: Build
>    Affects Versions: 1.7, 1.8
>         Environment: Java , Linux, Jboss
>            Reporter: raghutpk
>              Labels: commons, configuration
>             Fix For: 1.9
>
>   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

        

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

Posted by "Oliver Heger (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CONFIGURATION-478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13229616#comment-13229616 ] 

Oliver Heger commented on CONFIGURATION-478:
--------------------------------------------

Any news here? I tend to close this ticket as I do not think we can do anything about it.
                
> Cannot write to files within an app server directory
> ----------------------------------------------------
>
>                 Key: CONFIGURATION-478
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-478
>             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

        

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

Posted by "Oliver Heger (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CONFIGURATION-478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13204322#comment-13204322 ] 

Oliver Heger commented on CONFIGURATION-478:
--------------------------------------------

Can you log the URL of the configuration you want to save: xmlConfig.getURL() ?

Without knowing too many details about JBoss's deployment mechanism, I assume that your application is not directly executed from the deploy folder, but copied into a working directory. Therefore, you probably end up with a URL pointing to a file in a virtual JBoss file system. That this file cannot be written is pretty clear.

In general, I do not think that it is a good idea to manipulate content of an application folder which has been deployed to a server. The directory is under control of the application server, and changing it - if possible at all - may have undesired side effects.

Further, I doubt that this issue is specific to Commons Configuration. You can check whether you are able to read, manipulate, and save any other file from your application directory.
                
> Cannot write to files within an app server directory
> ----------------------------------------------------
>
>                 Key: CONFIGURATION-478
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-478
>             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