JTA Transaction in servlet /EJB

From: Suman (smajumder_at_dvlp.com)
Date: 03/09/04


Date: 8 Mar 2004 21:45:49 -0800

This is regarding an auction site in which at the end of each auction
there is heavy bidding,which results in erroneous recording of bids
due to transaction failure.to counter that we tried to implement the
following...

Implement JTA transaction in my servlet.(Servlet is multi threaded)The
Servlet does a stateless session bean lookup which inturn calls the
create method of an entity bean(BMP).The session bean transaction att
is "supports" and the same for the BMP is "required".

The code snippet is as follows...
Context initialContext = new InitialContext();
UserTransaction userTran =
(javax.transaction.UserTransaction)initialContext.lookup("java:comp/UserTransaction");
userTran.begin();
System.out.println("Begin Transaction");
Context ctx = new InitialContext();
AutoBidManagerHome bidhome =
(AutoBidManagerHome)PortableRemoteObject.narrow(ctx.lookup("ejb/ejb/AutoBidManagerHome"),AutoBidManagerHome.class);
AutoBidManager BidObj = bidhome.create();
check=BidObj.processAutoBid();
userTran.commit();
System.out.println("End Transaction");

My problem is that the transactions are not getting executed one after
another when the servlet is requeted concurrently by 2 or more
different users as the server log shows "Begin Transaction","Begin
Transaction","End Transaction","End Transaction" in this order,instead
of Begin/End/Begin/End in order.
we tried implementing single thread model also.
Please help........

AppServer:Websphere5.0
DB :IBM DB28.1