I'm not sure if this will fix your problem, but try getting
   the classloader from the thread.

      Thread.currentThread().getContextClassLoader();
 
 

Savotchkin Egor wrote:

Hi all,     I needed to load property files on my own without ResourceBundle class because the latter does a lot of caching which I do not need. So I copied the code from ResourceBundle class where property files are loaded and included it in my application. The problem is all this thing works if I start orion by java com.evermind.server.ApplciationServer and does not work in case of java -jar orion.jar. Is this because of different classloaders or something else? The code is: class MessageResources {...    private static ClassLoader getLoader() {
        ClassLoader cl = MessageResources.class.getClassLoader();
        if (cl == null) {
            cl = ClassLoader.getSystemClassLoader();
        }
        return cl;
    } private InputStream loadResourceAsStream(final String resName) {
        final ClassLoader loader = getLoader();
        InputStream stream = (InputStream)java.security.AccessController.doPrivileged(
            new java.security.PrivilegedAction() {
                public Object run() {
                    if (loader != null) {
                        return loader.getSystemResourceAsStream(resName);
                    } else {
                        return ClassLoader.getSystemResourceAsStream(resName);
                    }
                }
            }
        );
        return stream;
    }..}

Reply via email to