J2EE Interview Questions -2

Question: What is Deployment Descriptor? Answer: A deployment descriptor is simply an XML(Extensible Markup Language) file with the extension of .xml. Deployment descriptor describes the component deployment settings. Application servers reads the deploy

J2EE Interview Questions -2

J2EE Interview Questions -2 

     

Question: What is Deployment Descriptor?
Answer: A deployment descriptor is simply an XML(Extensible Markup Language) file with the extension of .xml. Deployment descriptor describes the component deployment settings. Application servers reads the deployment descriptor to deploy the components contained in the deployment unit. For example ejb-jar.xml file is used to describe the setting of the EJBs.

Question: What do you understand by JTA and JTS?
Answer: JTA stands for Java Transaction API and JTS stands for Java Transaction Service. JTA provides a standard interface which allows the developers to demarcate transactions in a manner that is independent of the transaction manager implementation. The J2EE SDK uses the JTA transaction manager to implement the  transaction. The code developed by developers does not calls the JTS methods directly, but only invokes the JTA methods. Then JTA internally invokes the JTS routines. JTA is a high level transaction interface used by the application code to control the transaction.
  

Question: What is JAXP?
Answer: The Java API for XML Processing (JAXP) enables applications to parse and transform XML documents independent of a particular XML processing implementation. JAXP or Java API for XML Parsing is an optional API provided by Javasoft. It provides basic functionality for reading, manipulating, and generating XML documents through pure Java APIs. It is a thin and lightweight API that provides a standard way to seamlessly integrate any XML-compliant parser with a Java application.
More at http://java.sun.com/xml/ 
 

Question: What is J2EE Connector architecture?
Answer: J2EE Connector Architecture (JCA) is a Java-based technology solution for connecting application servers and enterprise information systems (EIS) as part of enterprise application integration (EAI) solutions. While JDBC is specifically used to connect Java EE applications to databases, JCA is a more generic architecture for connection to legacy systems (including databases). JCA was developed under the Java Community Process as JSR 16 (JCA 1.0) and JSR 112 (JCA 1.5). As of 2006, the current version of JCA is version 1.5.
The J2EE Connector API is used by J2EE tools developers and system integrators to create resource adapters. Home page for J2EE Connector architecture http://java.sun.com/j2ee/connector/
 

Question: What is difference between Java Bean and Enterprise Java Bean?
Answer: Java Bean as is a plain java class with member variables and getter setter methods. Java Beans are defined under JavaBeans specification as Java-Based software component model which includes the features like introspection, customization,  events,  properties and  persistence. 
Enterprise JavaBeans or EJBs for short are Java-based software components that comply with Java's  EJB specification. EJBs are delpoyed on the EJB container and executes in the EJB container. EJB is not that simple,  it is used for building distributed applications. Examples of EJB are Session Bean, Entity Bean and Message Driven Bean. EJB is used for server side programming whereas java bean is a client side. Bean is only development but the EJB is developed and then deploy on EJB Container.
 

Question: What is the difference between JTS and JTA?
Answer: In any J2EE application
transaction management is one of the most crucial requirements of the application. Given the complexity of today's business requirements, transaction processing occupies one of the most complex segments of enterprise level distributed applications to build, deploy and maintain.  JTS specifies the implementation of a Java transaction manager. JTS specifies the implementation of a Transaction Manager which supports the Java Transaction API (JTA) 1.0 This transaction manager supports the JTA, using which application servers can be built to support transactional Java applications. Internally the JTS implements the Java mapping of the OMG OTS 1.1 specifications. The Java mapping is specified in two packages: org.omg.CosTransactions and org.omg.CosTSPortability. The JTS thus provides a new architecture for transactional application servers and applications, while complying to the OMG OTS 1.1 interfaces internally. This allows the JTA compliant applications to interoperate with other OTS 1.1 complaint applications through the standard IIOP. Java-based applications and Java-based application servers access transaction management functionality via the JTA interfaces. The JTA interacts with a transaction management implementation via JTS. Similarly, the JTS can access resources via the JTA XA interfaces or can access OTS-enabled non-XA resources. JTS implementations can interoperate via CORBA OTS interfaces.

The JTA specifies an architecture for building transactional application servers and defines a set of interfaces for various components of this architecture. The components are: the application, resource managers, and the application server. The JTA specifies standard interfaces for Java-based applications and application servers to interact with transactions, transaction managers, and resource managers JTA transaction management provides a set of interfaces utilized by an application server to manage the beginning and completion of transactions. Transaction synchronization and propagation services are also provided under the domain of transaction management.

In the Java transaction model, the Java application components can conduct transactional operations on JTA compliant resources via the JTS. The JTS acts as a layer over the OTS. The applications can therefore initiate global transactions to include other OTS transaction managers, or participate in global transactions initiated by other OTS compliant transaction managers.
 

Question: Can Entity Beans have no create() methods?
Answer:
Entity Beans can have no create() methods. Entity Beans have no create() method, when entity bean is not used to store the data in the database. In this case entity bean is used to retrieve the data from database.
  

Question: What are the call back methods in Session bean?
Answer:
Callback methods are called by the container to notify the important events to the beans in its life cycle.  The callback methods are defined in the javax.ejb.EntityBean interface.The callback methods example are ejbCreate(), ejbPassivate(), and ejbActivate().
  

Question: What is bean managed transaction?
Answer:
In EJB transactions can be maintained by the container or developer can write own code to maintain the transaction. If a developer doesn?t want a Container to manage transactions, developer can write own code to maintain the database transaction.
 

Question: What are transaction isolation levels in EJB?
Answer: Thre are four levels of transaction isolation are:
* Uncommitted Read
* Committed Read
* Repeatable Read
* Serializable
The four transaction isolation levels and the corresponding behaviors are described below:

Isolation Level

Dirty Read

Non-Repeatable Read

Phantom Read

Read Uncommitted

Possible

Possible

Possible

Read Committed

Not possible

Possible

Possible

Repeatable Read

Not possible

Not possible

Possible

Serializable

Not possible

Not possible

Not possible