Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Volatile property files

 
Graham Mead
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
We have a J2EE application which contains a property file for MQ settings that we need change on a frequent basis. This is currently only referenced from code in the WAR file.
Initially we put this in a jar in the EAR referenced by the WAR manifest, because later modules may need access to it. However being in a jar this makes it a pain to update.

Where is the recommended J2EE place within the WAR,EAR or elsewhere so that a) the code can find it, we are using this.getClass().getClassLoader().getResourceAsStream() to load it. and b) we can gain access to it easily to modify the contents?
Thanks for any help
Graham
 
Greg Charles
Sheriff
Posts: 2993
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've run up against this problem several times, but I don't have a great solution. As far as I can tell, it's impossible to update a properties file in a jar. The best bet is to put it on the file system, possibly at a location defined by a system property. I usually use WebLogic, so I set this system property using a -D option in the startWebLogic script.
BTW, this.getClass().getResourceAsStream(String) should work for reading. Why do you need to retrieve the class loader?
 
Graham Mead
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi thanks for the reply
We use the getClassLoader method first to ensure that we are attaining the right level of module visibility within J2EE.
This was after discussing visibility problems with IBM and it is also referred to in Tim Deboers article and on other websites I've seen concerning the same problems.
He says
"A common portable technique for finding resources (property files, images, and so on) is to use the classloader's findResourceXX methods. Based on the previous discussion, you can see why it is important to use the right classloader for this job. For example, if you use the WebSphere classloader, you won't be able to find any resources in your modules"

http://www7b.software.ibm.com/wsdd/library/techarticles/0112_deboer/deboer.
 
Graham Mead
Ranch Hand
Posts: 57
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic