This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Transaction error - please help.  RSS feed

 
J Waldinger
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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
 
Juan Rolando Prieur-Reza
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!