
Hi friends,
i am trying a simple HelloWOrld EJb on Websphere Applicatiopn server 6.1. Can any one plz help me to solve this issue.
here is the client code which i have written.
package com.ibm.pck;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import com.ibm.ejb.example;
import com.ibm.ejb.exampleHome;
public class exampleClient {
public static void main(String args[]) {
try {
Properties props = new Properties();
props.put(Context.INITIAL<em>CONTEXT</em>FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory ");
props.put(Context.PROVIDER_URL, "iiop://localhost:900");
Context initialContext = new InitialContext(props);
Object objref = initialContext.lookup("ejb/com/ibm/ejb/exampleHome"); <br />
exampleHome home = (exampleHome)PortableRemoteObject.narrow(objref, exampleHome.class); <br />
example myHelloWorld = home.create(); <br />
String message = myHelloWorld.sayHello(); <br />
System.out.println(message); <br />
}
catch (Exception e) {
e.printStackTrace(); <br />
System.exit(2);
}
}
}
i am getting these errors while i am runnign above client.
javax.naming.NoInitialContextException: Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory [Root exception is java.lang.ClassNotFoundException: com.ibm.websphere.naming.WsnInitialContextFactory ]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:669)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:259)
at javax.naming.InitialContext.init(InitialContext.java:235)
at javax.naming.InitialContext.<init>(InitialContext.java:209)
at com.ibm.pck.exampleClient.main(exampleClient.java:21)
Caused by: java.lang.ClassNotFoundException: com.ibm.websphere.naming.WsnInitialContextFactory
at java.lang.Class.forName(Class.java:164)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:57)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:666)
... 4 more

EJB Hello World Example
Please visit the following links:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.