How to call an EJB 2 from an EJB 3 ?

JBoss recipe of the day

The EJB 3 specification mandates that all container should support EJB 2 as well. It's even possible to inject an EJB 2 into an EJB 3. Here's how to do it:


public InsertOrderBean implements InsertOrder {
public BankAccountHome bankAccountHome;
void payorder(){
BankAccount bankAccount
=  bankAccountHome.create();



Here the BankAccountHome in injected into the EJB InsertOrderBean and, inside method payorder(), used to take one instance of the BankAccount Bean from the pool


Related articles available on

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


In a Bean Managed Transaction, the code in the session or message

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

Follow us on Twitter