I have a servlet that uses the Sun's jndi classes to access a LDAP database.
I have a test program that can run my servlet's jndi access methods without any problem.
When I install and run the servlet under tomcat, the class loader throws a ClassNotFoundException
for the com.sun.jndi.ldap.LdapCtxFactory class.
(Stack trace shown below.)
I have the jndi jar files in the WEB-INF/lib directory along with the jar file for my servlet code.
Why can't tomcat load the same classes that my test program can if the same jar files are used in both cases?
How can I determine the classpath that is in effect when my servlet is attempting to load the class?
(I tried using System.getProperty("java.class.path") but the results didn't even show the jar file containing
my servlet classes, so I know this is not showing me the true classpath)
Here is the stack trace at the time of the error:
--------------------------------------------------------------------------------------------
javax.naming.NoInitialContextException
Cannot instantiate class: com.sun.jndi.ldap.LdapCtxFactory
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.ldap.LdapCtxFactory. Root exception is java.lang.ClassNotFoundException: com.sun.jndi.ldap.LdapCtxFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java, Compiled Code)
at java.lang.Exception.<init>(Exception.java, Compiled Code)
at java.lang.ClassNotFoundException.<init>(ClassNotFoundException.java, Compiled Code)
at java.net.URLClassLoader$1.run(URLClassLoader.java, Compiled Code)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java, Compiled Code)
at java.lang.ClassLoader.loadClass(ClassLoader.java, Compiled Code)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java, Compiled Code)
at java.lang.ClassLoader.loadClass(ClassLoader.java, Compiled Code)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java, Compiled Code)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:199)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:49)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:660)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:250)
at javax.naming.InitialContext.init(InitialContext.java:226)
at javax.naming.InitialContext.<init>(InitialContext.java:202)
at javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:87)
at com.avaya.onemeeting.authentication.LDAPAuthenticator.getUserContext(LDAPAuthenticator.java:117)
at com.avaya.onemeeting.authentication.LDAPAuthenticator.authenticate(LDAPAuthenticator.java:36)
at com.avaya.onemeeting.authentication.AuthServlet.authenticate(AuthServlet.java:136)
at com.avaya.onemeeting.authentication.AuthServlet.authenticate(AuthServlet.java:118)
at com.avaya.onemeeting.authentication.AuthServlet.doGet(AuthServlet.java:71)
at com.avaya.onemeeting.authentication.AuthServlet.doPost(AuthServlet.java:102)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:166)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java, Compiled Code)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java, Compiled Code)
at java.lang.Thread.run(Thread.java:479)
