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
posted Jun 10, 2004 06:01:00
0
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
subject: what is EJB-REF