File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Volatile property files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Volatile property files" Watch "Volatile property files" New topic
Author

Volatile property files

Graham Mead
Ranch Hand

Joined: Sep 28, 2001
Posts: 57
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

Joined: Oct 01, 2001
Posts: 2864
    
  11

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

Joined: Sep 28, 2001
Posts: 57
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

Joined: Sep 28, 2001
Posts: 57
Apologies that should behttp://www7b.software.ibm.com/wsdd/library/techarticles/0112_deboer/deboer.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Volatile property files