In the web.xml of your war, have the following entry:

<ejb-ref>
  |     
<ejb-ref-name>GiveAnyNameByWhichYouWouldLikeToReferTheBeanInYourWebApp</ejb-ref-name>
  |     <ejb-ref-type>session</ejb-ref-type>
  |     <home>packageName.ClassNameOfTheHomeObjectOfTheBeanYouWantToRefer</home>
  |     
<remote>packageName.ClassNameOfTheRemoteObjectOfTheBeanYouWantToRefer</remote>
  |   </ejb-ref>  

  In the jboss-web.xml of your war, have the following entry:
  
  <ejb-ref>
  |             
<ejb-ref-name>GiveAnyNameByWhichYouWouldLikeToReferTheBeanInYourWebApp(This 
should be same as the one given in the web.xml above)</ejb-ref-name>
  |             
<jndi-name>TheJndiNametoWhichTheBeanIsBound(Example:somecontext/somejndiName)YouWillFindThisJndiNameInTheJboss.xmlOfTheEJB</jndi-name>
  |     </ejb-ref>
        

For more info, have a look at the dtds of web.xml :
http://java.sun.com/dtd/web-app_2_3.dtd

 and jboss-web.xml:
 http://www.jboss.org/j2ee/dtd 

  
  In your code, do the lookup as:
  
  Context ic = new InitialContext();
  |   Object ejbHome = 
ic.lookup("java:comp/env/TheNameThatYouHadGivenInTheEJB-REF-NAMETagOfJbossWeb.xmlAbove");

Here's an example:

web.xml:


  <ejb-ref>
  |     <ejb-ref-name>MyTestBean</ejb-ref-name>
  |     <ejb-ref-type>session</ejb-ref-type>
  |     <home>com.test.ejb.MyBeanHome</home>
  |     <remote>com.test.ejb.MyBeanRemote</remote>
  |   </ejb-ref>



jboss-web.xml:


  |     <ejb-ref>
  |             <ejb-ref-name>MyTestBean</ejb-ref-name>
  |             <jndi-name>myejb/test/MyTestBean</jndi-name>
  |     </ejb-ref>      

Lookup code:


        Context ic = new InitialContext();
  |   Object ejbHome = ic.lookup("java:comp/env/MyTestBean");



View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3953891#3953891

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3953891

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to