File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes what is EJB-REF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "what is EJB-REF" Watch "what is EJB-REF" New topic

what is EJB-REF

akilan irudaya raja

Joined: Feb 19, 2004
Posts: 26
Hi All,

what is <EJB-REF> in web.xml
and how to use that


Java Programmar SCJP,SCWCD,SCBCD.
Malli Raman
Ranch Hand

Joined: Nov 07, 2001
Posts: 312
Originally posted by akilan irudaya raja:
Hi All,

what is <EJB-REF> in web.xml
and how to use that


If your servlets is referring any EJB's you have mention the EJB Name in the EJB-REF.
Sivasundaram Umapathy
Ranch Hand

Joined: Aug 10, 2002
Posts: 360
<ejb-ref> is used to refer to an EJB from the web application. For ex: If you need to use a EJB for which you don't know the JNDI name in the real environment,you can use ejb-ref as


and refer from your servlet as

InitialContext ctx = new InitialContext();
MyBeanHome home = (MyBeanHome) ctx.lookup("java:comp/env/ejb/MyBean");
MyBean bean = home.create();

The deployer would resolve this reference while deploying the WAR in the application server.


p.s. It's ejb-ref and not EJB-REF. Remember that the descriptor elements are case sensitive

Co-Author - SCMAD Exam Guide - ISBN:9780070077881
Author - Java certification success, Part 4: SCEA
I agree. Here's the link:
subject: what is EJB-REF
It's not a secret anymore!