This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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.
 
 
subject: How to identify existing Transaction?
 
Similar Threads
How to pass an arrayList from a JSP to a servlet.
Unable to retrieve value in JSP
Help needed Regardng Tree Structure
help needed Regarding tree Structure
Passing an Array to a Javascript function