关闭

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

305人阅读 评论(0) 收藏 举报
 

HTML Tags and JavaScript tutorial



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





In the web.xml of your war, have the following entry:
Code:
<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:
Code:
 <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:
Code:
  Context ic = new InitialContext();
  Object ejbHome = ic.lookup("java:comp/env/TheNameThatYouHadGivenInTheEJB-REF-NAMETagOfJbossWeb.xmlAbove"); 
Here's an example:
web.xml:
Code:
<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:
Code:
 <ejb-ref>
  <ejb-ref-name>MyTestBean</ejb-ref-name>
  <jndi-name>myejb/test/MyTestBean</jndi-name>
 </ejb-ref> 
Lookup code:
Code:
Context ic = new InitialContext();
  Object ejbHome = ic.lookup("java:comp/env/MyTestBean"); 
 


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:150678次
    • 积分:4030
    • 等级:
    • 排名:第7748名
    • 原创:242篇
    • 转载:0篇
    • 译文:0篇
    • 评论:16条
    文章存档
    最新评论