File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Accsessing EJB in the web application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Accsessing EJB in the web application" Watch "Accsessing EJB in the web application" New topic

Accsessing EJB in the web application

Alka S.

Joined: Nov 29, 2003
Posts: 26
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?
I agree. Here's the link:
subject: Accsessing EJB in the web application
jQuery in Action, 3rd edition