*
The moose likes Websphere and the fly likes Initial Context Factory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Initial Context Factory" Watch "Initial Context Factory" New topic
Author

Initial Context Factory

Venkat Ammisetty
Ranch Hand

Joined: Nov 25, 2000
Posts: 42
Hai
Can any one tell me what could be the error in the following code
Hashtable ht2=new Hashtable();
ht2.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.Websphere.naming.WsnInitialContextFactory");
ht2.put(Context.PROVIDER_URL,"iiop://localhost");
Context cxt=new InitialContext(ht2);
I am getting the following exception
[01.09.20 15:03:32:090 PDT] 6130ab1c WebGroup X Servlet Error: Cannot instantiate class: com.ibm.Websphere.naming.WsnInitialContextFactory: javax.naming.NoInitialContextException: Cannot instantiate class: com.ibm.Websphere.naming.WsnInitialContextFactory. Root exception is java.lang.ClassNotFoundException: com.ibm.Websphere.naming.WsnInitialContextFactory
Begin backtrace for rootCause
java.lang.ClassNotFoundException: com.ibm.Websphere.naming.WsnInitialContextFactory
Is any thing wrong in Initial Context Factory?
Thank's in advance
Venkat

Venkat Ammisetty
Chee
Greenhorn

Joined: Jan 23, 2001
Posts: 16
Hi..
You are using the wrong intial context factory. Pl refer any of samples.
Rgds
Johnson
Originally posted by Venkat Ammisetty:
Hai
Can any one tell me what could be the error in the following code
Hashtable ht2=new Hashtable();
ht2.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.Websphere.naming.WsnInitialContextFactory");
ht2.put(Context.PROVIDER_URL,"iiop://localhost");
Context cxt=new InitialContext(ht2);
I am getting the following exception
[01.09.20 15:03:32:090 PDT] 6130ab1c WebGroup X Servlet Error: Cannot instantiate class: com.ibm.Websphere.naming.WsnInitialContextFactory: javax.naming.NoInitialContextException: Cannot instantiate class: com.ibm.Websphere.naming.WsnInitialContextFactory. Root exception is java.lang.ClassNotFoundException: com.ibm.Websphere.naming.WsnInitialContextFactory
Begin backtrace for rootCause
java.lang.ClassNotFoundException: com.ibm.Websphere.naming.WsnInitialContextFactory
Is any thing wrong in Initial Context Factory?
Thank's in advance
Venkat

Jun Hong
Ranch Hand

Joined: Sep 05, 2001
Posts: 181
Put com.ibm.Websphere.naming.WsnInitialContextFactory in your classpath. Also, use iiop://localhost:900 is better. You need a port number for iiop.


Jun Hong<br />SCJP, SCJD, SCWCD, SCEA<br />IBM Certified Systems Expert(V4.0)
Jun Hong
Ranch Hand

Joined: Sep 05, 2001
Posts: 181
I used com.ibm.ejs.ns.jndi.CNInitialContextFactory for 3.5 and com.ibm.websphere.naming.WsnInitialContextFactory for 4.0. I think com.ibm.websphere.naming.WsnInitialContextFactory is in ns.jar.
Jun Hong
Venkat Ammisetty
Ranch Hand

Joined: Nov 25, 2000
Posts: 42
Hai thank's for user suggestions.
Yes there is a mistake in my Initial Context Factory that is case sensitivity i.e. I used Websphere insted of websphere in the following context and port number for URL is 900.
com.ibm.websphere.naming.WsnInitialContextFactory
iiop://localhost:900
Now I am able to run my application on WebSphere 4.0 Single Server Edition.
The Initail Context Mentioned as
com.ibm.ejs.ns.jndi.CNInitialContextFactory
is also correct but it is deprecated that's why I used earlier one.
Thank's one and all for your help.
Bye
Venkat
vinodbabuc chandramohan
Greenhorn

Joined: May 10, 2005
Posts: 2
Hi,
I am also facing the same problem in websphere6.1. Please do help us.
We are getting the following error while migrating from websphere6.0 to websphere6.1.
junit] java.lang.ClassNotFoundException:
[junit] com.ibm.websphere.naming.WsnInitialContextFactory
[junit]
[junit] at java.lang.Class.forName(Class.java:160)
[junit] at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:57)
[junit] at com.actiontech.jmetro.server.config.Jndi.getContext(Jndi.java:114)
[junit] at com.actiontech.jmetro.client.Config$ServiceLocator.getContext(Config.java:127)
[junit] at com.actiontech.jmetro.client.Config$ServiceLocator.(Config.java:118)
[junit] at com.actiontech.jmetro.client.Config$ServiceLocator.(Config.java:106)
[junit] at java.lang.J9VMInternals.initializeImpl(Native Method)
[junit] at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)

The code which we are running is
java.util.Hashtable appContext = new java.util.Hashtable();
appContext.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
appContext.put(javax.naming.Context.PROVIDER_URL, "iiop://localhost:2809");
Context context = new InitialContext(appContext);
Object objref = context.lookup("AdminSessionBean");
Object obj = PortableRemoteObject.narrow(objref, com.actiontech.jmetro.server.ejb.AdminSessionHome.class);
EJBHome home = (EJBHome) obj;

we have added the plugins\com.ibm.ws.runtime_6.1.0.jar which contains com.ibm.websphere.naming.WsnInitialContextFactory in the websphere6.1 cclasspath but still we get the same error.
Can somebody help us in fixing the above error.
Thanks in advance,
Vinod
bigamy bilk
Greenhorn

Joined: Jun 06, 2009
Posts: 2
try with naming.jar
 
 
subject: Initial Context Factory
 
Similar Threads
Error in Loading WAR file
JNDI Context problem
getting the InitialContext problem
Problem finding InitialContext
Unable to connect to Data Source