• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accsessing EJB in the web application

Alka S.
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Tomcat as web server and Weblogic as application server.
I have deployed EJBs on Weblogic. I have to use these EJBs in Jsps (Action classes). Code is as follows
As MVC architecture I am calling EJB in ction class
public ActionForward execute(ActionMapping actionMapping,ActionForm actionForm,HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, "tc://localhost:7001");
Context initCtx = new InitialContext(p);
Object obj = initCtx.lookup("myFacilityService");
FacilityServiceHome home = (FacilityServiceHome)PortableRemoteObject.narrow(obj,
//Create the remote interface instance
FacilityService cli = home.create();
httpServletRequest.setAttribute("FacilityList", cli.getAllFacility());
In jsp
Integer val = (Integer)request.getAttribute("FacilityList");
String counrVal = " ";
if (val != null)
counrVal = val.toString();
I have copied ejb jar file which is deployed on weblogic on WEB_INF-lib folder and added in JBuilder for required libraries. It is coplling properly but while running it is giving erroras follows -
Error -----------------------------------Cannot instantiate class: weblogic.jndi
After copying weblogic.jar in Tomact - common - lib folder it is giving error null.
Can anybody knows the above problem?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic