JavaBeat FAQs
Sponsors
JAVABEAT
Home
Articles
Tips
QnA
Forums
FAQs Topics Books Topic
Java Java Books
Struts Struts Books
Spring Spring Books
Hibernate Hibernate Books
JBoss Seam Seam Books
J2EE J2EE Books
EJB EJB Books
JSF JSF Books
Servlets Servlets Books
JDBC JDBC Books
RMI RMI Books
JMS JMS Books
JNI JNI Books
Design Patterns Patterns Books
Exception Exception Books
Apache Ant Ant Books
Groovy
Cobertura
Quartz

Enterprise Java Beans(EJB) Interview Questions

EJB FAQs - 1 | EJB FAQs - 2 | EJB FAQs - 3 | EJB FAQs - 4 | EJB FAQs - 5 | EJB FAQs - 6 | EJB FAQs - 7 | EJB FAQs - 8 | EJB FAQs - 9 | EJB FAQs - 10 | EJB FAQs - 11 | EJB FAQs - 12

61) Can the primary key in the entity bean be a Java primitive type such as int?
 

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).

62) How do I map a Date/Time field to an Oracle database with CMP?
 

[Question continues: (I have written a wrapper class with the help of java.util.GregorianCalendar but it doesn't store time in Oracle database, whereas it stores Date without any problem.)]

Use the java.sql.Timestamp field to store your Date/Time in your entity bean, and then declare the corresponding field as 'Date' type in the Oracle database and it will work fine. You will have the "date" value and the "time" value preserved.

63) What is the difference between a Server, a Container, and a Connector?
 

To keep things (very) simple:

An EJB server is an application, usually a product such as BEA WebLogic, that provides (or should provide) for concurrent client connections and manages system resources such as threads, processes, memory, database connections, network connections, etc.

An EJB container runs inside (or within) an EJB server, and provides deployed EJB beans with transaction and security management, etc. The EJB container insulates an EJB bean from the specifics of an underlying EJB server by providing a simple, standard API between the EJB bean and its container.

(Note: The EJB 1.1 specification makes it clear that it does not architect the interface between the EJB container and EJB server, which it says it left up to the vendor on how to split the implementation of the required functionality between the two. Thus there is no clear distinction between server and container.)

A Connector provides the ability for any Enterprise Information System (EIS) to plug into any EJB server which supports the Connector architecture.

64) What is "clustering" in EJB?
 

Clustering refers to the ability of multiple load-balanced web servers to share session and entity data. It is a major feature of web application servers. Standardized support for clustering was one of the primary motivations behind the EJB spec.

Clustering also applies to Servlet containers sharing HttpSession data (similar to EJB Session Beans).

65) What is "hot deployment" in WebLogic?
 

"Hot Deployment" in weblogic is the act of deploying, re-depolying, and un-deploying EJBs while the server is still running (you don't have to shutdown the server to deploy an EJB).

66) Can I specify specific WHERE clauses for a find method in a CMP Entity Bean?
 

The EJB query language is totally vendor specific in EJB1.1. It is being standardized in 1.2.

Yes, you can specify the where clause for a find method. This is the example for EJB's deployed on weblogic:

findBigAccounts(double balanceGreaterThan): "(> balance $balanceGreaterThan)"

where balance maps to some field in the table.

67) When using a stateful session bean with an idle timeout set, how can the bean receive notification from the container that it is being removed due to timeout?
 

[Question continues: ? (Through some tests, it looks like none of the standard EJB callback methods are called when a stateful session bean is removed due to idle-timeout.)]

According to the spec, ejbRemove need not (or must not) be called in this case. ejbPassivate is simply the Wrong Thing to be called (the bean is transitioning to the 'does not exist' state, not the 'passive' state).

The EJB 1.1. spec says in section 6.6.3 Missed ejbRemove Calls:

The application using the session bean should provide some clean up mechanism to periodically clean up the unreleased resources.

For example, if a shopping cart component is implemented as a session bean, and the session bean stores the shopping cart content in a database, the application should provide a program that runs periodically and removes “abandoned” shopping carts from the database.

Probably not the answer you're looking for, especially if you allocate some other resource (a Message Queue, for example) that you need to release. Although, if you're using a resource, you really should be getting it when you need it (via JNDI) and returning it back to the pool right away.

68) 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?
 

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.

69) What is the difference between a Component Transaction Monitor (CTM) and an Application Server?
 

A Component Transaction Monitor (CTM) is an application server that uses a server-side component model. Since a CTM is a Transaction Processing monitor (TP), it is expected to provide services for managing transactions, security, and concurrency. In addition, CTMs also facilitate distributed object architectures and provide facilities for object persistence. In short, a CTM is a specific type of application server.

70) How can I call one EJB from inside of another EJB?
 

Just do it!

EJBs can be clients of other EJBs. It just works. Really. Use JNDI to locate the Home Interface of the other bean, then acquire an instance reference, and so forth.

Bookmark This Page : | | | | | | | | | | |
Related Articles
Liferay Portal Enterprise Intranets
ZK Developer’s Guide : Online Media Library
The BIRT Environment and Your First Report
AJAX - The Complete Reference
The Java 6.0 Compiler API
Spring Web Flow - Introduction
Introduction to Spring Web Framework
Integrating Struts With Spring
What's new in Struts 2.0? - Struts 2.0 Framework
Introductiion to Jakarta Struts
more articles
java6 ejb3 jsf hibernate eclipse ajax groovy spring seam java struts webservice j2me guice java5 jca tapestry soa linux ria

Sponsors
Webmaster Hosting Forum
Java Jobs
Latest in DLinks
http://javawave.blogspot.com/2008/04/quartz-job-scheduler-part-ii-example.html
Quartz Job Scheduler -- Part 1 (Setting up development project in Netbeans 6.1 beta)
Flex Messaging with BEA Workshop Studio
SOA and Virtualization: How do They Fit Together?
Introduction to Enterprise Portals - Why they Benefit IT and the Business
BEA WebLogic Operations Control: Application Virtualization for Enterprise Java
Best Practices for Building Production Quality EAR Files
BEA's SOA Reference Architecture - A Foundation for Business Agility
Blueprint for Successful SOA Integration
Guardian - What a tool!

JavaBeat Media (2004-2008), India
javabeat home | About Us
our network : opensource softwares
Copyright © 2007 JavaBeat