• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is this a Nested Transaction?

 
Adilson Jardim
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hy,

I have a Stateless Sessin Bean CMT(trans-atributte= Required) that use a DAO with Hibernate, MBean service in jboss, like persistence layer.
The hibernate Mbean Service use UserTransaction interface supplied by container.

The following problem ocurred:

When a stand-alone remote client access this Bean and invoke sucessfuly my business method, that use dao objets, in the next time that any method that invoke any dao methods, this last throws a NullPointerException when the hibernate try take a getUserTransaction.

I learned that nested transactions are not suported in EJB. Would be any problem when any method those dao objects, call getUserTransaction inside a EJB CMT?


Thanks for all!

Adilson
 
Alex Sharkoff
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Adilson,

If I understood your post correctly you're asking whether it is possible to call EJBContext#getUserTransaction inside the ejb that is CMT ( <transaction-type>Container</transaction-type>).

The answer to this question is that it is illegal to use javax.transaction.UserTransaction in CMT ejb and the Container will throw java.lang.IllegalStateException if this is the case. javax.transaction.UserTransaction can be only used for BMT ejb (<transaction-type>Bean</transaction-type>).

Hope it helps
 
Adilson Jardim
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Alex!!

This is the problem. I don�t call getUserTransaction() in my EJB context object.
As I said, the hibernate use the UserTransaction interface, therefore this is not visible for me.
In realy, I don�t understanding the problem. The call for the method getUserTransaction is made indirectly by a POJO and not by a EJB.

If exists a transaction, initiate by EJB, the DAO-hibernate object will go to use the same transaction or it starts a new transaction?

Thanks for any tip!!
[ July 19, 2004: Message edited by: Adilson Jardim ]
 
Alex Sharkoff
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Adilson,


The call for the method getUserTransaction is made indirectly by a POJO and not by a EJB.


It does not matter whether an ejb makes a direct call to EJBContext#getUserTransaction() or an ejb passes the control to POJO, which then makes a call to EJBContext#getUserTransaction().

If an ejb is CMT then all POJOs it talks to during a method execution can only perform operations that are legal for CMT beans.

Therefore, the following is illegal

CMT ejb -> POJO -> EJBContext#getUserTransaction()



Hope it helps
 
Adilson Jardim
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alex,
thanks for your help !!
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I learned that nested transactions are not suported in EJB.
Would be any problem when any method those dao objects, call getUserTransaction inside a EJB CMT?


You use hibernate with JBoss , so you can getUserTransaction from Session of Hibernate , you may not getUserTRansaction from EJBContext because some exception will occur when you set some config wrong.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic