Solved

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

Posted on 2006-07-01
3
586 Views
Last Modified: 2013-11-24
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,
0
Comment
Question by:dkim18
  • 2
3 Comments
 
LVL 92

Expert Comment

by:objects
Comment Utility
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
0
 

Author Comment

by:dkim18
Comment Utility
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)
0
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
Comment Utility
how r u running your app? appears to not be reading your classpath
have u tried copying the jar to the ext directory of the jre you are running
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now