Thursday, 9 May 2013

How to call any EJB from a servlet/JSP/Java Client? | EJB Interview Questions

Context ctx = new InitialContext();
//get Home interface of bean
//narrow -retype
BeanHome lhome = (BeanHome) javax.rmi.PortableRemoteObject.narrow(ctx.lookup("cz.train.Bean"), BeanHome.class);
//get remote interface
Bean lbean = lhome.create();
//now you can call bussiness method on remote interface like
lbean.doSomething()

No comments: