Tomcat developers, please correct me if I am wrong but as far as I know
Tomcat 3.2 does not set ContextClassLoader for its threads. So you are using
main class loader which knows nothing about your WEB-INF/lib
I had a different problem - when code loaded by main classloader need to
load classes from WEB-INF/lib. I solved it by writing request and context
interceptors for tomcat to call
Thread.currentThread().setContextClassLoader() for each thread before it
touches a servlet (doing init/destroy or serving request) 

-----Original Message-----
From: Sean Dowd [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 12, 2000 10:12 AM
To: [EMAIL PROTECTED]
Subject: Re: ServletContext.getResourceAsStream() in 3.2?


> If you want to load a file that is under WEB-INF, you don't need to
involve the
> class loader at all.  Simply use:
>
>    InputStream is =
>
getServletContext().getResourceAsStream("/WEB-INF/myprops.properties");

Cool.  That works (missed the part about relative to the context
directory
in the javadoc).

But now I'm back to the classloading issue.  I'm trying to use JNDI and
the 
call to load the factory class is failing.  The JNDI code is doing
something
like this to load the factory:

    String className = "com.netscape.jndi.ldap.LdapContextFactory";
    try
      {
      // this works
//       Class c = Class.forName( className );
      // this does not
      ClassLoader loader =
(java.lang.ClassLoader)java.security.AccessController.doPrivileged(new
java.security.PrivilegedAction() {
      
      public java.lang.Object run()
        {
        return java.lang.Thread.currentThread().getContextClassLoader();
        }
      
      });
      Class c = java.lang.Class.forName(className, true, loader);
      log( "Class " + className + " loaded." );
      }
    catch ( Exception e )
      {
      log( "Error loading class " + className + ": " + e );
      return;
      }

I'm seeing a ClassNotFoundException but the jar is definitely in
WEB-INF/lib
and definitely contains com.netscape.jndi.ldap.LdapContextFactory.

Reply via email to