Supposing you have deployed an Enterprise Java Bean as stand alone application and you want to access it from your Servlet / Jsp layer. What you need to do is adding the appropriate references to your web.xml and jboss-web.xml.

So if you have an EJB named "HelloBean" add to your web.xml

<ejb-ref>
    <ejb-ref-name>HelloBean</ejb-ref-name>  
    <ejb-ref-type>session</ejb-ref-type>  
    <home>test.HelloBeanHome</home>  
    <remote>test.HelloBeanRemote</remote>  
</ejb-ref>

Then modify jboss-web.xml by adding:

<ejb-ref>
  <ejb-ref-name>HelloBean</ejb-ref-name>  
  <jndi-name>HelloBean</jndi-name>  
</ejb-ref>

Now you can safely lookup your EJB from your Servlet:

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

0
0
0
s2smodern

Related articles available on mastertheboss.com

EJB 3.0 tutorial : Session Beans

Enterprise JavaBeans (EJB) technology is a J2EE technology for de

JBoss MDB 3.0

Message-driven beans (MDBs) are stateless, server-side, transacti

JBoss EJB 3 BMT

In a Bean Managed Transaction, the code in the EJB or Message Dri

How do you keep your EJB callbacks separated from biz. methods?

JBoss daily recipe

How to set EJB timeout period ?

JBoss recipe of the day

How to add a Selector with MDB 3.0 ?

Message selectors allow an MDB to be more selective about the mes