Top 29 Enterprise Java Beans (EJB) Interview Questions You Must Prepare 19.Mar.2024

EJBDoclet is an open source JavaDoc doclet that generates a lot of the EJB related source files from custom JavaDoc comments tags embedded in the EJB source file.

EJB is a specification for J2EE server, not a product.
Java be may be a graphical component in IDE.

An EJB client JAR file is an optional JAR file that can contain all the class files that a client program needs to use the client view of the enterprise be that are contained in the EJB JAR file. If you decide not to create a client JAR file for an EJB module, all of the client interface classes will be in the EJB JAR file.

Callback methods allows the container to notify the bean of events in its life cycle. The callback methods are defined in the javax.ejb.EntityBean interface.

Session and Entity EJBs consist of 4 and 5 parts respetively:
@A remote interface (a client interacts with it).
@A home interface (used for creating objects and for declaring business methods).
@A bean object (an object, which actually performs business logic and EJB-specific operations).
@A deployment descriptor (an XML file containing all information required for maintaining the EJB) or a set of deployment descriptors (if you are using some container-specific features).
5.A Primary Key class - is only Entity bean specific.

For a Session bean - one EJB object for one bean instance.
For entity bean - it depends , if 2 users are accessing one row at time then one EJB object is used for both the be other wise for each bean one EJB object.

If we define the entity bean as being reentrant, multiple clients can connect to the Entity bean & execute methods within the entity bean concurrently. Container takes care of synchronization. If we define the entity bean as non-reentrant and many clients connect to it concurrently to execute a method, exception is thrown .

 

@Traction_read_uncommitted- Allows a method to read uncommitted data from a DB(fast but not wise).
@Traction_read_committed- Guarantees that the data you are getting has been committed.
@Traction_repeatable_read - Guarantees that all reads of the database will be the same during the traction (good for read and update operations).
@Traction_serializable- All the tractions for resource are performed serial.

An EJB container is a run-time environment that manages one or more enterprise be. The EJB container manages the life cycles of enterprise bean objects, coordinates distributed tractions, and implements object security. Generally, each EJB container is provided by an EJB server and contains a set of enterprise be that run on the server.

 

Entity be that have container-managed relationships with other entity be, must be accessed in the same local scope as those related be, and therefore typically provide a local client view. In order to be the target of a container-managed relationship, an entity bean with container-managed persistence must provide a local interface.

It must be abstract class. The container extends it and implements methods which are required for managing the relationships

The process of propagating the changes in the properties of a server group during runtime to all the associated clones is called Ripple Effect.

EJB technology is the core of J2EE. It enables developers to write reusable and portable server-side business logic for the J2EE platform.

Deployment descriptor is a XML file. which is used to locate the web applicatio n by container.it includes the details of respective bean.

1.The local client view specification is only available in EJB 2.@Unlike the remote client view, the local client view of a bean is location dependent.
2.Local client view access to an enterprise bean requires both the local client and the enterprise bean that provides the local client view to be in the same JVM.
3.The local client view therefore does not provide the location trparency provided by the remote client view. Local interfaces and local home interfaces provide support for lightweight access from enterprise bean that are local clients.
4.Session and entity be can be tightly couple with their clients, allowing access without the overhead typically associated with remote method calls.

 

A server group is a template of an Application Server(and its contents) i.e, it is a logical representation of the application server. It has the same structure and attributes as the real Application Server, but it is not associated with any node, and does not correspond to any real server process running on any node.

1.An MDB is essentially a message consumer that can listen to a message destination or a message endpoint and gets activated when a message arrives.
2.By design, MDBs are anonymous in nature and hence cannot be directly invoked by a client.
3.The only way to invoke an MDB is to send a message to the destination or endpoint to which it is listening.
@As MDBs are stateless in nature and are not related to any specific client, they can be pooled for concurrent processing of messages.

 

We can use the Java 2 Platform, Enterprise Edition Client Access Services (J2EETM CAS) COM Bridge 1.0, currently downloadable from Sun

An entity bean represents persistent global data from the database; a session bean represents trient user-specific data that will die when the user disconnects (ends his session). Generally, the session be implement business methods (e.g. Bank.trferFunds) that call entity be (e.g. Account.deposit, Account.withdraw)

1.It manages the execution of enterprise be for J2EE applications.
2.Enterprise be and their container run on the J2EE server.

Container services are totally depends upon the “vendor implementation”. But more or less most of the vendors suppots the basic services like,
LifeCycle Management - It is Automatic.
Session Management - it is used by Developer coded callback methods…
Traction Management - it is used by configuring deployment descriptor (DD) .
Security management - it is used by configuring deployment descriptor (DD) .
The other services, if any will be in advanced versions, and depends on Vendor specific.

Although technically it is legal, static initializer blocks are used to execute some piece of code before executing any constructor or method while instantiating a class. Static initializer blocks are also typically used to initialize static fields - which may be illegal in EJB if they are read/write - In EJB this can be achieved by including the code in either the ejbCreate(), setSessionContext() or setEntityContext() methods

The process by which the contents in the memory of one physical m/c are replicated in all the m/c in the cluster is called in-memory replication.

Yes. In some cases the data is inserted NOT using Java application, so you may only need to retrieve the information, perform its processing, but not create your own information of this kind.

The copies of a server group are called Clones. But unlike a Server Group Clones are associated with a node and are real server process running in that node.

Steps:
1: Retrieve Home Object reference from Naming Service via JNDI.
2: Return Home Object reference to the client.
3: Create me a new EJB Object through Home Object interface.
4: Create EJB Object from the Ejb Object
5: Return EJB Object reference to the client.
6: Invoke business method using EJB Object reference.
7: Delegate request to Bean (Enterprise Bean).

 

1.EJB QL is a Query Language provided for navigation across a network of enterprise be and dependent objects defined by me of container managed persistence.
2.EJB QL is introduced in the EJB 2.0 specification.
3.The EJB QL query language defines finder methods for entity be with container managed persistence and is portable across containers and persistence managers.
4.EJB QL is used for queries of two types of finder methods:
               Finder methods that are defined in the home interface of an entity bean and which return entity objects.Select methods, which are not exposed to the client, but which are used by the Bean Provider to select persistent values that are maintained by the Persistence Manager or to select entity objects that are related to the entity bean on which the query is defined.

1.The remote client view specification is only available in EJB 2.0.
@The remote client view of an enterprise bean is location independent.
3.A client running in the same JVM as a bean instance uses the same API to access the bean as a client running in a different JVM on the same or different machine.
Remote interface: The remote interface specifies the remote business methods that a client can call on an enterprise bean.
Remote home interface: The remote home interface specifies the methods used by remote clients for locating, creating, and removing instances of enterprise bean classes.

 

There are two types of scaling: Vertical Scaling and Horizontal Scaling.
Vertical Scaling - When multiple server clones of an application server are defined on the same physical m/c, it is called Vertical Scaling. The objective is to use the processing power of that m/c more efficiently.
Horizontal Scaling - When Clones of an application server are defined on multiple physical m/c, it is called Horizontal Scaling. The objective is to use more than one less powerful m/c more efficiently.