Technical Sample Questions : C |
Java | Unix |
Operating Systems |
Java Sample Questions ›› EJB Java Sample Questions
Java Technical Sample Questions : EJB Sample Questions
« Previous || Next »
EJB Sample Question Number :
- Can an EJB send asynchronous notifications to its clients?
Answer: Asynchronous notification is a known hole in the first versions of the EJB spec.The recommended solution to this is to use JMS, which is becoming available in J2EE-compliant servers.The other option, of course, is to use client-side threads and polling.This is not an ideal solution, but it's workable for many scenarios.
- Is there a guarantee of uniqueness for entity beans?
Answer: There is no such guarantee.The server (or servers) can instantiate as many instances of the same underlying Entity Bean (with the same PK) as it wants.However, each instance is guaranteed to have up-to-date data values, and be transactionally consistent, so uniqueness is not required.This allows the server to scale the system to support multiple threads, multiple concurrent requests, and multiple hosts.
- 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.
- I have created a remote reference to an EJB in FirstServlet.Can I put the reference in a servlet session and use that in SecondServlet?
Answer: Yes.The EJB client (in this case your servlet) acquires a remote reference to an EJB from the Home Interface; that reference is serializable and can be passed from servlet to servlet.If it is a session bean, then the EJB server will consider your web client's servlet session to correspond to a single EJB session, which is usually (but not always) what you want.
- Can the primary key in the entity bean be a Java primitive type such as int?
Answer: The primary key can't be a primitive type-use the primitive wrapper classes, instead.For example, you can use java.lang.Integer as the primary key class, but not int (it has to be a class, not a primitive)
- What's new in the EJB 2.0 specification?
Answer: Following are the main features supported in EJB 2.0: Integration of EJB with JMS, Message Driven Beans, Implement additional Business methods in Home interface which are not specific for bean instance, EJB QL.
- How many types of protocol implementations does RMI have?
Answer: RMI has at least three protocol implementations: Java Remote Method Protocol(JRMP), Internet Inter ORB Protocol(IIOP), and Jini Extensible Remote Invocation(JERI).These are alternatives, not part of the same thing, All three are indeed layer 6 protocols for those who are still speaking OSI reference model.
- What is the need of Remote and Home interfaces.Why can't there be one?
Answer: In a few words, I would say that the main reason is because there is a clear division of roles and responsabilities between the two interfaces.The home interface is your way to communicate with the container, that is who is responsable of creating, locating even removing one or more beans.The remote interface is your link to the bean, that will allow you to remotely access to all its methods and members.As you can see there are two distinct elements (the container and the beans) and you need two different interfaces for accessing to both of them.
- 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.
- Question With regard to Entity Beans, what happens if both my EJB Server and Database crash, what will happen to unsaved changes? Is there any transactional log file used?
Answer: Actually, if your EJB server crashes, you will not even be able to make a connection to the server to perform a bean lookup, as the server will no longer be listening on the port for incoming JNDI lookup requests.You will lose any data that wasn't committed prior to the crash.This is where you should start looking into clustering your EJB server.Any unsaved and uncommited changes are lost the moment your EJB Server crashes.If your database also crashes, then all the saved changes are also lost unless you have some backup or some recovery mechanism to retrieve the data.So consider database replication and EJB Clustering for such scenarios, though the occurence of such a thing is very very rare.Thx, Uma All databse have the concept of log files(for exampe oracle have redo log files concept).So if data bases crashes then on starting up they fill look up the log files to perform all pending jobs.But is EJB crashes, It depend upon the container how frequenlty it passivates or how frequesntly it refreshes the data with Database.