You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Mike Williams <md...@bigfoot.com> on 2002/09/26 14:21:05 UTC

Class.forName() vs getContextClassLoader()

I've been having problems loading my custom LogSystem, of the form

    java.lang.ClassNotFoundException: my.LogSystem

and it seems it's because my LogSystem class is in a different (child)
class-loader to Velocity.

I tried working around it using

    Thread.currentThread().setContextClassLoader( Generator.class.getClassLoader() );

but it seems Velocity is still using Class.forName(), so I'm stuck.  Any
chance of changing Class.forName() to something like:

    Class c = null;
    try {
        c = Thread.currentThread().getContextClassLoader().loadClass( className );
    } catch (ClassNotFoundException e) {
        c = getClass().getClassLoader().loadClass( className );
    }

or is it necessary to retain 1.1 compatibility?

-- 
cheers, Mike

"Whenever I feel blue, I start breathing again."

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Class.forName() vs getContextClassLoader()

Posted by Mike Williams <md...@bigfoot.com>.
  >>> On 26 Sep 2002 22:21:05 +1000,
  >>> "Mike" == Mike Williams <md...@bigfoot.com> wrote:

  Mike> Any chance of changing Class.forName() to something
  Mike> [... getContextClassLoader().loadClass() ...], or is it necessary
  Mike> to retain 1.1 compatibility?

Geir, any thoughts on this one?

-- 
cheers, Mike

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>