Link to home
Start Free TrialLog in
Avatar of dkim18
dkim18

asked on

Already set weblogic.jar in the classpath, but "cannot instantiate class: weblogic.jndi.WLInitialContextFactory" error.

Hi,

I have set weblogic.jar in classpath, but still having this error.

Error  NamingException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory

This is part of code:
+++++++++++++++++++++++++
public void PrintStudentInfo(){
             Context initcntx = null;
               Hashtable ht = new Hashtable();  
               ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
               ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
               ht.put(Context.SECURITY_PRINCIPAL, "userId");  
               ht.put(Context.SECURITY_CREDENTIALS, "password");  

BTW, this is just java program.

thanks,
Avatar of Mick Barry
Mick Barry
Flag of Australia image

it may not be that it can't find the class, instead that for some reasone it is failing to create it.
try displaying the full stack trace
Avatar of dkim18
dkim18

ASKER

javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory]
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:652)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
      at javax.naming.InitialContext.init(InitialContext.java:219)
      at javax.naming.InitialContext.<init>(InitialContext.java:195)
      at PrintStudentInfoFromPool.PrintStudentInfo(PrintStudentInfoFromPool.java:30)
      at PrintStudentInfoFromPool.main(PrintStudentInfoFromPool.java:66)
Caused by: java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory
      at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:219)
      at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)
      ... 5 more
java.lang.NullPointerException
      at PrintStudentInfoFromPool.PrintStudentInfo(PrintStudentInfoFromPool.java:58)
      at PrintStudentInfoFromPool.main(PrintStudentInfoFromPool.java:66)
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial