Home Java Technology EJB EJB Sample Interview Questions - 6

Login Form




EJB Sample Interview Questions - 6 Print E-mail

1. What are the different kinds of enterprise beans?
Answer: Different kind of enterrise beans are:


Stateless session bean
Stateful session bean
Entity bean
Message-driven bean

2. What does a remove method do for different cases of beans?
Answer: Stateless Session : Does not do anything to the bean as moving the bean from free pool to cache are managed by the container depending on load.Stateful Session: Removes the bean from the cache.Entity Bean: Deletes the bean (data) from persistent storage

3. What is a Server Group?
Answer: 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.

4. What is the basic requirement for in-memory replication in Weblogic?
Answer: The data in session should consist only of Serialized objects.Only setAttribute function should be used to set objects in session.

5. Is it possible to stop the execution of a method before completion in a SessionBean?
Answer: Stopping the execution of a method inside a Session Bean is not possible without writing code inside the Session Bean.This is because you are not allowed to access Threads inside an EJB.

6. Why is ejbFindByPrimaryKey mandatory?
Answer: An Entity Bean represents persistent data that is stored outside of the EJB Container/Server.The ejbFindByPrimaryKey is a method used to locate and load an Entity Bean into the container, similar to a SELECT statement in SQL.By making this method mandatory, the client programmer can be assured that if they have the primary key of the Entity Bean, then they can retrieve the bean without having to create a new bean each time - which would mean creating duplications of persistent data and break the integrity of EJB.

7. Is method overloading allowed in EJB?
Answer: Yes you can overload methods

8. Is there any way to read values from an entity bean without locking it for the rest of the transaction (e.g.read-only transactions)? We have a key-value map bean which deadlocks during some concurrent reads.Isolation levels seem to affect the database only, and we need to work within a transaction.
Answer: The only thing that comes to (my) mind is that you could write a 'group accessor' - a method that returns a single object containing all of your entity bean's attributes (or all interesting attributes).This method could then be placed in a 'Requires New' transaction.This way, the current transaction would be suspended for the duration of the call to the entity bean and the entity bean's fetch/operate/commit cycle will be in a separate transaction and any locks should be released immediately.Depending on the granularity of what you need to pull out of the map, the group accessor might be overkill.

9. How do the six transaction attributes map to isolation levels like "dirty read"? Will an attribute like "Required" lock out other readers until I'm finished updating?
Answer: The Transaction Attributes in EJB do not map to the Transaction Isolation levels used in JDBC.This is a common misconception.Transaction Attributes specify to the container when a Transaction should be started, suspended(paused) and committed between method invocations on Enterprise JavaBeans.For more details and a summary of Transaction Attributes refer to section 11.6 of the EJB 1.1 specification.

10. What is the difference between Java Beans and EJB?
Answer: Java Beans are client-side objects and EJBs are server side object, and they have completely different development, lifecycle, purpose.