• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTA Transaction in servlet

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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........
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do u think that really matters.....If yes how?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic