• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem finding InitialContext

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a stand alone Java Application running on WSAD 5.1. How do i get the initialcontext???

I am using the code

Hashtable props = new Hashtable ();
props.put (Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
props.put(Context.PROVIDER_URL,"iiop://localhost:2809");
Context ctx = new InitialContext(props);



It gives the following error.

javax.naming.NoInitialContextException: Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory. Root exception is java.lang.ClassNotFoundException: com.ibm.websphere.naming.WsnInitialContextFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:374)
at java.lang.ClassLoader.loadClass(ClassLoader.java:562)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:438)
at java.lang.ClassLoader.loadClass(ClassLoader.java:494)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:256)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:59)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:661)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:256)
at javax.naming.InitialContext.init(InitialContext.java:232)
at javax.naming.InitialContext.<init>(InitialContext.java:208)
at test.LocalTest.mail(LocalTest.java:46)
at test.LocalTest.main(LocalTest.java:35)


Please help.

Regards, Vishva
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where is this java application file located? Try placing the file in EJB project and J2EE project. If the file is in Java client project - it wouldn't find the EJB context.

There could be some other ways to create the EJBContext - if you want to test it real quick, the above ways should work
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well thats a pretty obvious exception, you don't have the naming.jar in your classpath, you probably will need other dependencies as well from the websphere app\lib directory.
 
Vishva Rajput
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vishi / Andre,

Thanks!
It works fine the way you suggested. How come? Also I need to run it as a standalone application, JUnit, what do i need to do. Add naming.jar, and what else.

Vishva
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic