You can't use the system classloader for this.  Try the current threads context 
classloader (Thread.currentThread().getContextClassLoader()).

Regards,
Sebastian

-----Original Message-----
From:   Brian Wallis [mailto:[EMAIL PROTECTED]
Sent:   Wed 10/15/2003 1:25 AM
To:     [EMAIL PROTECTED]
Cc:     
Subject:        [JBoss-user] JBoss classpaths and ClassLoader.getSystemClassLoader()

(running jboss 3.2.1 on linux 2.4.7 kernel)

There is the following bit of code in the J2SE 1.4 class
java.util.prefs.Preferences..

> private static final PreferencesFactory factory;
> static {
>     String factoryName =
>     (String) AccessController.doPrivileged(new PrivilegedAction() {
>           public Object run() {
>               return System.getProperty(
>                          "java.util.prefs.PreferencesFactory");
>           }
>     });
> 
>     if (factoryName == null)
>         throw new InternalError(
>             "System property java.util.prefs.PreferencesFactory not set");
> 
>     try {
>         factory = (PreferencesFactory)
>            Class.forName(factoryName, false,
>                  ClassLoader.getSystemClassLoader()).newInstance();
>     }catch(Exception e) {
>         throw new InternalError(
>             "Can't instantiate Preferences factory " + e);
>     }
> }

The idea is that you can define your own factory and set the property 
java.util.prefs.PreferencesFactory  to point to it. Then your new factory 
will return instances of your implementation of the Preferences class.

Problem is, as far as I understand it, the call getSystemClassLoader() is not 
going to return a classloader that will load a class from a deployed jar 
file, or even from a jar file in the jboss lib directory. Only jars on the 
actual java classpath are seen (ie "-classpath xxx.jar").

Certainly I have failed to get it to work thusfar. 

I've tried putting my preference factory class jar file on the JBOSS_CLASSPATH 
(which ends up as option value for -classpath to java)  and then it seems to 
be loaded, but I also use jboss's Logger, SecurityAssociation and 
ServerConfig classes and they are not found. They are in the lib or server 
lib directories and I assume are not seen by the classloader returned by 
getSystemClassLoader().

Help!

thanks, brian wallis...



_______________________________________________________
This message is for the named recipient's use only.  It may contain sensitive and 
private proprietary information.  No confidentiality is waived or lost by any 
incorrect transmission.  If you are not the intended recipient, please immediately 
delete it and all copies of it from your system, destroy any hard copies of it and 
notify the sender.  You must not, directly or indirectly, use, disclose, distribute, 
print, or copy any part of this message if you are not the intended recipient.  
Sakonnet Technology, LLC and its subsidiaries reserve the right to monitor all e-mail 
communications through their networks. Any views expressed in this message are those 
of the individual sender, except where the message states otherwise and the sender is 
authorized to state them to be the views of any such entity.  Unless otherwise stated, 
any pricing information given in this message is indicative only, is subject to change 
and does not constitute an offer to deal at any price quoted. Any reference to the 
terms of executed transactions should be treated as preliminary only and subject to 
our formal written confirmation. 

<<winmail.dat>>

Reply via email to