EJB Interview Questions and Answers

1) What is EJB?

An EJB container is a highly abstracted Java EE implementation of the component model popularized by Java EE. It’s a runtime object that works on top of a TCP connection and exposes the services exposed by the controller (web server, Ajax API, etc.) to other objects that can then access and bind to those services. The EJB specification defines a number of abstractions that implement most of the concepts in the following sections. Interfaces: the service implementation provided by EJB containers. EJB classes are invoked using the interface API to perform binding requests to the services that are exposed by the container. You access the services using bean methods. You can subscribe to events sent from other objects, listening on an event channel: event handlers can be registered to execute actions when the corresponding event occurs. Services are abstracted by their names and methods. You can inject EJB classes into a class using a marker. You can provide a container with its own services via a provider, with these services in the Container.component in a configuration file. You can extend the container by providing custom services via a provider.

2) What are the types of Enterprise Bean?

Enterprise Bean refers to a hardware device that communicates with Cisco’s HyperFlex OS. The beans communicate using a standard protocol called “Cisco ISE”. The hardware bean is capable of handling any workload type on HyperFlex, including Cisco UCS servers.

3) What is session bean?

Session beans are entities that persist in memory as part of the main activity. The idea is that you can do state management in such an efficient way that it scales with your activity’s activity life-time. But state management is not always necessary. Sometimes you need to quickly access some external data that is persisted elsewhere. Session beans are accessible via a method name: (…) Again: Since a session bean must be initialized to initialize it with a specific value. Once this has been done, it can persist. In case of failures, it will be logged. In case of data retrieval, it will be fetched again, since it will reference the same set of objects. Fare better than regular beans!

4) What is stateless session bean?

In Python, a session bean is a Python class that holds a handle to a Python database, which serves as the entry point for the DBC persistence layer. However, this is actually not the only role that a session bean plays.

The session bean is actually the entry point for the persistence layer (a.k.a. the persistence layer from the class.db module), and the persistence layer from the class.db module is a list of session beans.

But, let’s be fair to session bean – it’s not the only way to hold the session state for a Postgres database. In fact, you can instead, in Python, do a subselect on the row to get the session state, then write that state in a table variable in your application code. This still works fine, but it is not the same as having a key-value store inside your application.

I’ll explain why in a moment. So, just to be clear, with a session bean, you have a key-value store that is actually a database. In this sense, session beans are a superset of the SQL/DLMS adapter code.

But let’s go back to the essence of session beans. With a session bean, the persistence layer does not hold the state, the persistence layer has the state. Now, when you ask a persistence layer session bean for the state, that persistence layer session bean holds the state, and then returns it to you.

5) Write down the steps for the creation of stateless EJB.

  • When you have the first version (or any version), test the creation.
  • If the test fails, make the changes.
  • Repackage the test unit for deployment.
  • Make sure it works. That’s it for now.

This is a tutorial, so there will be some duplication of work. If you are one of the people with 2.9-1 Roles installed, you’re all set. If you don’t have the Roles, go to Administration->Project->Roles and enable the “test” role. Don’t forget to make sure the black entry of the URL in <Template Tag> is white, otherwise a screenshot won’t work, or the new role won’t be deployed.

6) What is stateful session bean?

“Session Bean” is just another Java Persistence Beans that is responsible for validating and encrypting the session and carrying out all the activities related to the session like binding, locking and creating and destroying sessions. As we know there are different technologies such as Java Persistence API, JDBC, and also local persistence (which is in between session bean and JDBC).

To know more information about stateful session bean, just read our previous post. What is Spring Session Bean? Spring Session Bean is the same as Spring Session that is generally used in Spring MVC framework. In our simple Spring Framework example, we are going to use both spring session and spring session bean.

7) What is singleton session bean?

If you have a singleton session (session bean) based application, it could be helpful to have a singleton session bean, otherwise you are using it concurrently.

Every time you try to use an instance of the singleton session bean in a different context, it will crash and not allow you to access the outside world.

But if you have a singleton session, you could try to use the object directly in an external context (most of the times it is a private context), but it won’t work (it will try to hijack the context and crash the application, but that’s a topic for a future post).

Leave a comment

Your email address will not be published. Required fields are marked *