EJB Tutorials


Enterprise Java Beans or EJB for short is the server-side component architecture for the Java 2 Platform, Enterprise Edition (J2EE) platform. EJB technology enables rapid and simplified development of distributed, transactional, secure and portable applications based on Java technology.   Sun Microsystems in the beginning put forward Java Remote Method Invocation (RMI) API as a […]

Deploying and testing Stateless Session Bean

In this EJB tutorial we will build, deploy and test the Stateless Session Bean developed in the last section. We will use ant build tool to build ear file. We will deploy our application using WebLogic console. Building ear file using ant build tool I am assuming that you have ant build tool installed on […]

EJB Interview Questions

Here is a list of commonly asked interview questions about EJB. What is EJB ? EJB stands for Enterprise JavaBean and is a widely-adopted server side component architecture for J2EE. It enables rapid development of mission-critical application that are versatile, reusable and portable across middleware while protecting IT investment and preventing vendor lock-in. What is […]

Security in EJB

Security issues in EJBs are handled almost completely in the deployment descriptor .This allows changes in security rules without rewriting or recompiling Java code. The primary concept for EJB security is that of “roles”.  A user may be in one or more roles.  It is only roles that have particular access rights, not users.  So […]

Transaction handling in EJB

In database programming, often the concept of a “transaction” is used.  A transaction refers to one or more operations that are done in a tentative manner.  The programmer first states all operations to be done.  Then at the end, the programmer decides to commit to all the operations or to abort all of them.  If […]

Accessing JDBC from EJBs

We have already learned a little about the EJB’s environment.  We saw how linked EJB’s are available at JNDI names starting with the string java:comp/env/ Other resources are similarly available.  A very useful such resource is JDBC.  Of course, you can access JDBC as you have always been doing.  But EJB offers a standard method […]

Linked EJBs

In everything we have done so far, the model has been that the EJB runs on a server machine and its clients run elsewhere.  (As a special case, the “elsewhere” may happen to be the same machine.) But in an application designed using EJBs, it would be frequently necessary for one EJB to use the […]

EJB environment variables

One of the things that can be done in the deployment descriptor, is the setting of EJB “environment variables.” For example, suppose you write an EJB that will that is to be distributed to many of your customers. An example of such usage is a bank’s EJBs that need to know the interest rate.  Since […]

EJB Handles

In everything we have done so far, we have followed the standard model of locating a “home” object, and then using it to create or find the EJB. Also, since there are no finders in the case of session beans, once the program using a session bean exits, the bean is gone in our model. […]

Deploying the Session Bean

Deploying the session bean is similar to deploying the entity bean, but we don’t have to worry about a datasource, because entity beans are not backed up by persistent storage. We can modify the ejb.ini file as before and add just one line specifying the location of the “ejbJar”, but this is also not necessary. […]

Writing an EJB from scratch

We have been using an EJB wizard for doing our EJB development. In the future as EJB technology matures, it is likely that more and more EJB wizards will become available. However, at least once, it is a good idea to do everything “from scratch” without using a wizard.  By that it is not meant […]

An Overview of EJBs

This section gives an overview of EJBs EJBs are broadly classified into Entity Beans, Session Beans and Message-Driven Beans Entity Beans Java programmers are already familiar with objects.  An entity bean is an object with special properties: It is permanent. Standard Java objects come into existence when they are created in a program.  When the […]

What are EJBs?

An EJB is a server-side component that executes specific business logic. EJBs run on a server and are invoked by local or remote clients. A standardized contract exists between an application server and its EJB components that enables a component to run within any application server. The application server provides clearly-defined services while the components […]