The largest Interview Solution Library on the web

Interview Questions
« Previous | 0 | 1 | 2 | 3 | 4 | Next »

1.What is JTA?

Java Transaction API is a standard between the transaction manager and the entities participated in the distributed transaction system...

2.What is bean managed transaction?

A bean managed transaction is an explicitly bounded for a specific transaction that is handled by a bean...

3.What do you mean by demarcation? Explain the types of demarcation?

Demarcation and its types - Demarcation specifies a limit for a bean managed transaction...

4.Transactional attributes that the EJB supports?

Transactional attributes that the EJB supports - Required: This is the default transaction attribute that ensures the methods are invoked within Java Transaction API transaction context... From Wikipedia, the free encyclopedia

5.What is X/Open XA architecture.?

In the X/Open XA architecture, a transaction manager or transaction processing monitor (TP monitor) coordinates the transactions across multiple resources such as databases and message queues. Each resource has its own resource manager. The resource manager typically has its own API for manipulating the resource, for example the JDBC API to work with relational databases. In addition, the resource manager allows a TP monitor to coordinate a distributed transaction between its own and other resource managers. Finally, there is the application which communicates with the TP monitor to begin, commit or rollback the transactions. The application also communicates with the individual resources using their own API to modify the resource.

6.What is JTA implementation of the X/Open XA architecture.?

The JTA API consists of classes in two Java packages:

  • javax.transaction
  • javax.transaction.xa
  • The JTA is modelled on the X/Open XA architecture, but it defines two different APIs for demarcating transaction boundaries. It distinguishes between an application server such as an EJB server and an application component. It provides an interface, javax.transaction.TransactionManager, that is used by the application server itself to begin, commit and rollback the transactions. It provides a different interface, the javax.transaction.UserTransaction, that is used by general client code such as a servlet or an EJB to manage the transactions. The JTA architecture requires that each resource manager must implement the javax.transaction.xa.XAResource interface in order to be managed by the TP monitor. As stated previously, each resource will have its own specific API, for instance:
  • relational databases use JDBC
  • messaging services use JMS
  • generalized EIS (Enterprise Information System) resources [clarification needed] use Java EE Connector API.

7.What is Java Transaction API.?

The Java Transaction API consists of three elements: a high-level application transaction demarcation interface, a high-level transaction manager interface intended for an application server, and a standard Java mapping of the X/Open XA protocol intended for a transactional resource manager.

8.What is UserTransaction interface?

The javax.transaction.UserTransaction interface provides the application the ability to control transaction boundaries programmatically. This interface may be used by Java client programs or EJB beans. The UserTransaction.begin() method starts a global transaction and associates the transaction with the calling thread. The transaction-to-thread association is managed transparently by the Transaction Manager.
Support for nested transactions is not required. The UserTransaction.begin method throws the NotSupportedException when the calling thread is already associated with a transaction and the transaction manager implementation does not support nested transactions.
Transaction context propagation between application programs is provided by the underlying transaction manager implementations on the client and server machines. The transaction context format used for propagation is protocol dependent and must be negotiated between the client and server hosts. For example, if the transaction manager is an implementation of the JTS specification, it will use the transaction context propagation format as specified in the CORBA OTS 1.1 specification. Transaction propagation is transparent to application programs.

9.What is @Transactional annotation.?

The javax.transaction.Transactional annotation provides the application the ability to control transaction boundaries declaratively. This annotation can be applied to any class that the Java EE specification defines as a managed bean (which includes CDI managed beans).
The code sample below illustrates the usage of @Transactional in a request scoped CDI managed bean:

public class ExampleBean {

public void foo() { // A transaction is active here

// Do work

} // After the method returns transaction is committed or rolled back
Transactional behavior can be configured via an attribute on the annotation. The available options closely mirror those of the EJB specification.

10.What is @TransactionScoped annotation.?

The javax.transaction.TransactionScoped annotation provides the application the ability to declare that the scope during which a bean lives is tied to the time a given transaction is active.
The code sample below illustrates the usage of @TransactionScoped in a request scoped CDI managed bean:

public class TxScopedBean {
public int number;

public int getNumber() {return number;}
public void setNumber(int number) {this.number = number;}

public class ExampleBean {

private TxScopedBean tXscopedBean;

public void foo() {

public void bar() {
If method foo() is first called on a managed instance of ExampleBean and then subsequently method bar() is called, the number printed will be 0 and not 1. This is because each method had its own transaction and therefore its own instance of TxScopedBean. The number 1 that was set during the call to foo() will therefore not be seen during the call tobar().

11.What is UserTransaction support in EJB server.?

EJB servers are required to support the UserTransaction interface for use by EJB beans with the BEAN value in the javax.ejb.TransactionManagement annotation (this is called bean-managed transactions or BMT). The UserTransaction interface is exposed to EJB components through either the EJBContext interface using the getUserTransaction method, or directly via injection using the general @Resource annotation. Thus, an EJB application does not interface with the Transaction Manager directly for transaction demarcation; instead, the EJB bean relies on the EJB server to provide support for all of its transaction work as defined in the Enterprise JavaBeans Specification. (The underlying interaction between the EJB Server and the TM is transparent to the application; the burden of implementing transaction management is on the EJB container and server provider.[1])
The code sample below illustrates the usage of UserTransaction via bean-managed transactions in an EJB session bean:

public class ExampleBean {

private UserTransaction utx;

public void foo() {
// start a transaction

// Do work

// Commit it
utx.commit(); }
Alternatively, the UserTransaction can be obtained from the SessionContext:
public class ExampleBean {

private SessionContext ctx;

public void foo() {
UserTransaction utx = ctx.getUserTransaction();

// start a transaction

// Do work

// Commit it
Note though that in the example above if the @TransactionManagement(BEAN) annotation is omitted, a JTA transaction is automatically started whenever foo() is called and is automatically committed or rolled back when foo() is exited. Making use of a UserTransaction is thus not necessary in EJB programming, but might be needed for very specialized code.

12.What is UserTransaction support in JNDI.?

The UserTransaction should be available under java:comp/UserTransaction (if a JTA implementation is installed in the environment).

13.What is Open source JTA implementations.?

There exist a number of active (as of September 2010) open source JTA implementations. Narayana[edit]
Narayana, formerly known as JBossTS and Arjuna Transaction Service, comes with a very robust implementation, which supports both the JTA and JTS APIs. Narayana comes with a recovery service, which could be run as a separate process from your application processes. Narayana is the default transaction manager for Java EE WildFly and JBoss EAP application servers. It supports for three Extended Transaction models: Nested Top Level Transactions, Nested Transactions and a compensation-based model based on "Sagas".[2] Webservice and RESTful Transactions are supported as well.[3] It does not support out-of-the box integration with the Spring framework, but it is easy to integrate[4].
Atomikos TransactionsEssentials[edit]
Atomikos TransactionsEssentials's documentation and literature on the internet show that it is a production quality implementation, which also supports recovery and some exotic features beyond the JTA API. Atomikos provides out-of-the-box Spring integration along with some nice examples. It also provides support for pooled connections for both database and JMS resources.
Bitronix JTA[edit]
Bitronix claims to support transaction recovery as well as or even better than some of the commercial products. Bitronix also provides connection pooling and session pooling out of the box.

14.What is a transaction?

A transaction is an abstraction of an atomic and reliable execution sequence.
Transaction processing is important for almost all modern computing environments that support concurrent processing. In a distributed computing environment, if, for example, multiple clients were to interact with the same database table concurrently, it's possible that interleaved database operations could leave the table in an inconsistent state.
Transaction support is also important because systems can fail at any point in an execution sequence. If, for example, a database update operation involves several dependent tables, and the computer system fails when the database update is only partially completed, the database could be left in an inconsistent, even inoperable, state.
File and database processing were essential operations with early multiprocessing computing systems; hence, transaction processing was necessary to guarantee their integrity. In today's complex distributed environments, transactions are fundamental to many distributed operations, for example, guaranteed delivery and ordering of a series of messages exchanged between two distributed application components. In this scenario, the message exchange should take place within an atomic execution sequence.
During an atomic execution sequence a concurrency control algorithm manages interleaved operations to achieve the same effect as executing those operations in serial order. This algorithm includes, or calls on, a recovery algorithm that provides the logic necessary to undo and/or redo partially completed operations, depending on the execution context.
Concurrency control and recovery algorithms are based in part on serializability theory.

15.What is a distributed transaction?

A distributed transaction bundles multiple operations in which at least two network hosts are involved, for example, an enterprise bean deployed under an Enterprise JavaBean (EJB) server on network host jupiter that has a JDBC connection(s) to a database server on network host saturn. In enterprise computing, it's often the case that several network hosts are involved, each hosting different servers, for example, web servers, EJB servers, Java Message Service (JMS) servers, and other Java or CORBA-based application servers.
In order to satisfy a client's dependence on an all-or-nothing guarantee for a sequence of operations, a transaction manager is responsible for creating and managing a global transaction that encompasses all operations against the implied resources. The transaction manager accesses each resource, for example, a relational database system, through the respective resource manager

16.What is the acronym ACID?

ACID represents the four properties of every transaction:
• Atomicity - Either all of the operations bundled in the transaction are performed successfully or none of them are performed.
• Consistency - The transaction must leave any and all datastores that are affected by the transaction in a consistent state.
• Isolation - From the application's perspective, the current transaction is independent, in terms of application logic, from all other transactions running concurrently.
• Durability - The transaction's operations against a datastore must persist.

17.What parties are involved in transaction processing?

There are five principals:
• One or more client applications - optionally initiate client-based transactions
• One or more application servers - initiate transactions on behalf of clients
• The transaction manager - the intermediary between the clients and/or application server and the distributed transaction functionality
• One or more resource managers - for service access to external resources
• A communication resource manager - for propagation of transaction contexts

18.What is the Java Transaction API (JTA)?

JTA is a service-oriented API specification. Typically, we think of JTA as the service API used by application programmers to group operations into one or more logical transactions. JTA actually provides three types of services:
• Transactional operations in client applications
• Transactional operations in application servers performed on behalf of clients
• Global transactional management in a Java transaction manager coordinating multiple transaction-capable resource managers such as database servers and messaging systems
The most noticeable and often-used functionality isjavax.transaction.UserTransaction, which provides services for explicit client control of transactions.

19.What is the Java Transaction Service (JTS)?

JTS is a specification for implementing a Java transaction manager. A transaction manager serves as an intermediary between an application and one or more transaction-capable resource managers such as database servers and messaging systems. The JTS specification encompasses the JTA API specification.

20.How does a Java applet obtain a transaction object?

It shouldn't, no matter how clever the programmer! Applets, by definition, should be (very) thin clients. Transaction-related operations should be minimized even in end-user client applications. The main objective of enterprise computing is to factor distributed applications so that server-intensive operations are handled by server-side application components.

« Previous | 0 | 1 | 2 | 3 | 4 | Next »

copyright © 2014 - all rights riserved by