File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes How to identify existing Transaction? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to identify existing Transaction?" Watch "How to identify existing Transaction?" New topic
Author

How to identify existing Transaction?

Patrio Jensen
Greenhorn

Joined: Feb 20, 2009
Posts: 10
Hi,

I have created 2 SLSB say ParentBean and ChildBean. I am calling ChildBean from within ParentBean.

I am using CMT for both beans and have specified Required transaction attribute for both the beans.

My question is: How can I know whether container has created new transaction for the ChildBean or it's using that of ParentBean?

I tried printing hashcode for UserTransaction inside both beans but I am getting different values.

Thanks in advance.
Patrio Jensen
Greenhorn

Joined: Feb 20, 2009
Posts: 10
My mistake: I was getting UserTransaction using jndi lookup and not using EJBContext.getUserTransaction() call hence getting different values.

But now when I used getUserTransaction() method, I am getting error: Only instances of beans with bean-managed transaction demarcation can use getUserTransaction()

I realized that calling getUserTransaction() is not allowed for CMT beans as mentioned here

But still my question remains open.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to identify existing Transaction?