commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Srinivas Jonnalagadda <>
Subject Re: configuration --- get the properties object loaded after the delayed refresh
Date Thu, 08 Sep 2011 03:08:08 GMT


Even I saw that and the FCStrategy issue where  vfs is taken instead of file when I use the
Url concept. Then I changed to setFileName. I also used configurationutil.locate which actually
gave file notfound if I remember. After struggling for 2 weeks I am confused the use of this
commons configuration tool. My aim is to change a value in property file and get this reflect
application wide without restarting JBOSS/app server. I am writing some simple junit before
deploying to server and that itself is not working. I was expecting a simple framework without
me doing the polling etc.


On Sep 7, 2011, at 6:29 PM, Ralph Goers <> wrote:

Even the listener is triggered by something retrieving a property. There is no thread doing

However, if you are using this with JBoss 5+ I'm not sure the code below will work. I've had
developers reporting that JBoss is returning vfsfile as the protocol when the name is turned
into a URL and then ConfigurationUtil.fileFromURL fails.  They have reported that using VFSFileChangedReloadingStrategy
works fine with JBoss, although it isn't clear to me why since it doesn't explicitly support
the vfsfile protocol.


On Sep 7, 2011, at 12:07 PM, Srinivas Jonnalagadda wrote:


Thanks so i misunderstood the reload startegies. But what about the listeners. Can we trigger
signal to reload. I wanted to use ConfigurationChangedListener. But that still doesnt solve
the purpose right. For more clarity i am pasting the unit test i wrote:

srinivas jonnalagadda

public  void  testGetBuiltPropertyFileName() throws Exception {
PropertiesConfiguration config = new PropertiesConfiguration(); 
Properties props = null;
FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy(); 
props = ConfigurationConverter.getProperties(config);

From: Oliver Heger <>
To: Commons Users List <>
Sent: Wednesday, September 7, 2011 1:05 PM
Subject: Re: configuration --- get the properties object loaded after the delayed refresh

Am 07.09.2011 19:03, schrieb Srinivas Jonnalagadda:

Thanks for the reply. I wrote a JUNIT test and Below is the code. My aim was that when i set
the refresh delay to 500 and after the initial test passed i put a thread.sleep for 2 minutes.
when  the thread sleeps i am changing the value of the  JEDI_ENVIRONMENT to some thing else.
When the thread wakes up I wanted to see the props refreshed with new values so that the tes
tcase fails which means the program runs as expected. Pls help me.

Hi Srinivas,

somehow your code got mangled, so it is hardly readable.

But if I understand correctly, you obtain a Properties object from the 
configuration using something like

Properties props = ConfigurationConverter.getProperties(config);

Then you expect that the properties are automatically refreshed by the 
reloading strategy without any further action from your side, correct?

Well, the reloading strategies do not work that way unfortunately. 
Currently, there is no implementation which actively monitors a 
configuration file. Rather, the reloading strategy is only triggered 
when the configuration object is accessed, e.g. if a property is 
queried. FileChangedReloadingStrategy then checks the timestamp of the 
configuration file. If it has changed, it reloads the configuration. So 
you will only see new values if you query the configuration again.


Srinivas Jonnalagadda
@TestPropertiesConfiguration config =
Properties props =
FileChangedReloadingStrategy strategy =
props = ConfigurationConverter.getProperties(config);

publicvoidtestGetBuiltPropertyFileName() throwsException {newPropertiesConfiguration(); null;TEST_FILE);
newFileChangedReloadingStrategy(); "JEDI_ENVIRONMENT"),"TEST");"JEDI_ENVIRONMENT"),"TEST");"JEDI_ENVIRONMENT"),"TEST");out.println("Test");"JEDI_ENVIRONMENT"),"TEST");

From: Oliver Heger<>
To: Commons Users List<>
Sent: Saturday, September 3, 2011 11:05 AM
Subject: Re: configuration --- get the properties object loaded after the delayed refresh


Am 03.09.2011 07:59, schrieb Srinivas Jonnalagadda:

Below is the code for i wrote and seems at the propsConfig object gets refreshd after the
delay but the result object has the old values still. How do i get the new values into the
result object after the refresh. I am trying to create a Configuration listener as well and
that alos seems not to work.  The main objective for me is to get the properties object loaded
with new values without JBOSS server restart. Any help is appreciated.

Srinivas J

your code looks good, therefore I am not sure whether I fully understand
your problem.

How can you tell that the properties configuration object is refreshed
correctly when the result object still has the old values? Do you get
other results if you access the configuration object directly, e.g. by
calling propsConfig.getString("someKey") ? (If so, this would indicate a
bug in the ConfigurationConverter.getProperties() implementation.)


Properties result = null;
Configuration config = null;
URL resourceURL = null;
FileChangedReloadingStrategy refreshStrategy = new FileChangedReloadingStrategy();

PropertiesConfiguration propsConfig = new PropertiesConfiguration();
result = ConfigurationConverter.getProperties(propsConfig);

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message