File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Soft Skills 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
Author

what is EJB-REF

akilan irudaya raja
Greenhorn

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

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

Thanks
Akilan


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

Thanks
Akilan



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


<web-app>
<ejb-ref>
<ejb-ref-name>ejb/MyBean</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>MyBeanHome</home>
<remote>MyBean</remote>
</ejb-ref>
</web-app>

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.

HTH
Siva

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


Siva
Co-Author - SCMAD Exam Guide - ISBN:9780070077881
Author - Java certification success, Part 4: SCEA
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is EJB-REF