I have deployed a session bean in IBM WAS 5 using the console. The JNDI Name for that bean is "Mailer". Now I am trying to create a client in eclipse trying to access the session bean. I just added a whole bunch of IBM jar files to my project. I am confused how to do a look up to that bean. I have tried different ways. Attaching my client code ..
import javax.naming.Context;
import javax.naming.InitialContext;
import com.mweb.bsd.global.util.mailer.ejb.Mailer;
import com.mweb.bsd.global.util.mailer.ejb.MailerHome;
import java.util.*;
public class WebSphereMailerClient {
static
String url = "iiop://localhost:2809";
// static String url="iiop://localhost:2809/nodes/bsd-ggeorge/servers/server1";
public static void main(String args[]){
WebSphereMailerClient wClient =new WebSphereMailerClient();
try {
Context ctx = getInitialContext();
System.out.println("1..");
MailerHome home=(MailerHome)ctx.lookup("Mailer");
System.out.println("2");
Mailer mailer=home.create();
System.out.println("3");
System.out.println("..."+mailer.test("gmg"));
System.out.println("4");
} catch (Exception e) {
System.out.println("eee"+e);
}
}
public static Context getInitialContext() throws Exception {
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
p.put(Context.PROVIDER_URL, url);
/*
p.put("org.omg.CORBA.ORBClass","com.ibm.rmi.iiop.ORB");
p.put("org.omg.CORBA.ORBSingletonClass","com.ibm.rmi.corba.ORBSingleton");
p.put("javax.rmi.CORBA.UtilClass","com.ibm.rmi.javax.rmi.CORBA.Util");
p.put("javax.rmi.CORBA.StubClass","com.ibm.rmi.javax.rmi.CORBA.StubDelegateImpl");
p.put("javax.rmi.CORBA.PortableRemoteObjectClass","com.ibm.rmi.javax.rmi.PortableRemoteObject");
p.put("java.naming.factory.url.pkgs","com.ibm.ws.naming");
*/
return new InitialContext(p);
}
}