• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

what is EJB-REF

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

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

Thanks
Akilan
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<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
 
I would challenge you to a battle of wits, but I see you are unarmed - shakespear. Unarmed tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic