Korosh Afshar wrote:
I have a non-avalon application that loads properties using a singleton class with static accessor attributes.
This typically happens on VM startup and the properties are pulled in from a property file accessible from the system classpath.
So the static initializers for attributes are loaded up-front even before any of the lifecycle methods are called on my startup class.
I am moving this application to Avalon framework. Including myprops.properties in SAR-INF/myprops.properties does not seem to load any of the properties using:
InputStream in =
MySingltonClass.class.getClassLoader().getSystemResourceAsStream (
myprops.properties );
I get run time NullPointerException when trying to load the properties using above.
take a look at http://cvs.apache.org/viewcvs.cgi/avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/catalina/CatalinaSevak.java
(hope I got the link right).
for some sar code which loads a config file for an existing application. It works perfectly well.
2) It seems that I have to pass around Configuartion object to all classes requiring use of the properties. A singleton seemed to fix that.
Static singletons and avalon are not a very good match. One could say "Static Singletons are Considered Evil" in the multi-application multi-classloader universe. See http://avalon.apache.org/framework/guide-patterns-ioc.html and http://avalon.apache.org/developing/ for more pointers.
Can anyone suggest what is going on?
you're probably using a wrong URL. You need to provide more information (which version of phoenix are you using, stacktrace, error log) for a more specific answer. However, there's a better solution in Phoenix...
and also point me to document that explains how external property files from classapath and the SAR directory structure required to do this?
http://avalon.apache.org/api/org/apache/avalon/phoenix/BlockContext.html#getBaseDirectory()
use the result of that as your base URL, and then you don't need to worry 'bout anything else.
cheers!
- Leo
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
