File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is EJB-REF

 
akilan irudaya raja
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

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

Thanks
Akilan
 
Malli Raman
Ranch Hand
Posts: 312
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Sivasundaram Umapathy
Ranch Hand
Posts: 360
  • 0
  • Mark post as helpful
  • send pies
  • 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 agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic