• 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

Transaction error - please help.

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a stateless session bean with bean-managed transactions. It is throwing an IllegalStateException when it tries to call:
utx = mySessionCtx.getUserTransaction();
where utx is a javax.transaction.UserTransaction and mySessionCtx is a javax.ejb.SessionContext. The bean is defined as follows:
<session id="Session_1061575773750">
<ejb-name>ReservationManager</ejb-name>
<home>com.bostoncoach.gtx.ReservationManagerHome</home>
<remote>com.bostoncoach.gtx.ReservationManager</remote>
<ejb-class>com.bostoncoach.gtx.ReservationManagerBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
<env-entry id="EnvEntry_1061575892797">
<env-entry-name>ejb10-properties/loglevel</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>bleach</env-entry-value>
</env-entry>
</session>
According to JavaDoc, getUserTransaction throws "java.lang.IllegalStateException - The Container throws the exception if the instance is not allowed to use the UserTransaction interface (i.e. the instance is of a bean with container-managed transactions)."
However, according to the definition of my bean in the deployment descriptor, this is a stateless session bean with bean-managed transactions, and hence should be fine. So what's up?
Many thanks for any help.
Jamie
 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by J Waldinger:
...hence should be fine. So what's up?
...


just some thoughts...
be sure to call getUserTransaction in ejbCreate, not ejbActivate for SLSB.
and begin() before anything else.
no obvious problems. hmmmm.
 
Tomorrow is the first day of the new metric calendar. Comfort me tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic