• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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.
 
That is a really big piece of pie for such a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic