Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

About CMP transaction  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,my friends :
It is a puzzle how to user JTA in my CMP client. I wonder how to gain and use the ejbcontext instance to get a usertransaction ?
thanks!
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean a client application that is talking to an EJB? You get the UserTransaction from JNDI:
Context jndiCtx = new InitialContext();
// you may need properties for the InitialContext
UserTransaction tx = (UserTransaction)
jndiCtx.lookup("java:comp/UserTransaction");
tx.begin();
// ...
tx.commit();
// or tx.rollback();
If you are trying to get the UserTransaction from within a CMP bean, you can not - Entity beans should have declarative transactions (set in deployment descriptor).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!