• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTA Transaction in servlet

 
Suman Majumder
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to implement JTA transaction in my servlet.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 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.Please help........
 
john smith
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you creating an InitialContext for each lookup, rather than just using one?
[ March 08, 2004: Message edited by: cluck cluck ]
 
Suman Majumder
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do u think that really matters.....If yes how?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!