I am trying to do a JNDI lookup to get a handle on an
EJB (TrackHome). I am using WebSphere 6.0. My code is as follows:
Properties prop = new Properties();
prop.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
prop.setProperty(Context.PROVIDER_URL, "iiop://localhost:2809/");
javax.naming.InitialContext ctx = new InitialContext(prop);
Object obj = ctx.lookup("ejb/album/AlbumHome");
TrackHome ejbHome = (TrackHome)
PortableRemoteObject.narrow(obj,TrackHome.class);
But when I run it I get 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:375)
at java.lang.ClassLoader.loadClass(ClassLoader.java:562)
...
If I should not use "WsnInitialContextFactory", what should I use?
I am new to EJB, so please excuse me if this seems daft. Has anyone got any links to working with EJBs in WebSphere 6?
PS> I have tried "com.sun.jndi.fscontext.RefFSContextFactory", but get the following error:
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.fscontext.RefFSContextFactory. Root exception is java.lang.ClassNotFoundException: com.sun.jndi.fscontext.RefFSContextFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:375)
at java.lang.ClassLoader.loadClass(ClassLoader.java:562)
and "com.ibm.ejs.ns.jndi.CNInitialContextFactory" but get:
javax.naming.NoInitialContextException: Cannot instantiate class: com.ibm.ejs.ns.jndi.CNInitialContextFactory. Root exception is java.lang.ClassNotFoundException: com.ibm.ejs.ns.jndi.CNInitialContextFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:375)
at java.lang.ClassLoader.loadClass(ClassLoader.java:562)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:442)