You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Laird Nelson <lj...@gmail.com> on 2009/08/14 18:27:22 UTC
UserTransaction and container transactions
I'm still trying to figure out the cleanest way to zap an H2 database
between tests while using OpenEJB as a local server and making use of
OpenJPA's ability to generate the DDL for the database.
All of the EJBs under test will be using container-managed transactions.
All tests will inherit from a common test class. Is there a (cheap, dirty,
ugly) way within the superclass to get a handle on the *container*
transaction in effect for a given test, so I can roll it back?
I've tried grabbing the UserTransaction (an approach which of course is
positively blissful in its complete disregard of the specification) and
rolling it back, but of course I get an IllegalStateException telling me,
quite rightly, that there is no UserTransaction associated with the current
thread.
Any suggestions to solve the larger problem are heartily welcomed.
Best,
Laird
Re: UserTransaction and container transactions
Posted by David Blevins <da...@visi.com>.
Give the suggestion in the previous email a try. It should work for
the issue overall. If not, we can hammer on it some more :)
-David
On Aug 14, 2009, at 9:27 AM, Laird Nelson wrote:
> I'm still trying to figure out the cleanest way to zap an H2 database
> between tests while using OpenEJB as a local server and making use of
> OpenJPA's ability to generate the DDL for the database.
>
> All of the EJBs under test will be using container-managed
> transactions.
> All tests will inherit from a common test class. Is there a (cheap,
> dirty,
> ugly) way within the superclass to get a handle on the *container*
> transaction in effect for a given test, so I can roll it back?
>
> I've tried grabbing the UserTransaction (an approach which of course
> is
> positively blissful in its complete disregard of the specification)
> and
> rolling it back, but of course I get an IllegalStateException
> telling me,
> quite rightly, that there is no UserTransaction associated with the
> current
> thread.
>
> Any suggestions to solve the larger problem are heartily welcomed.
>
> Best,
> Laird