I solved this problem.
In fact I kept the @Resource
and @TransactionManagement
annotations.
I changed my SessionContext
into EJBContext
and I also changed my setSessionContext
like this:
EJBContext sessionContext;
...
@Resource
private void setSessionContext( EJBContext sctx )
{
this.sessionContext = sctx;
}
And in my method, to get the userTransaction
I do:
UserTransaction ut = null;
try
{
ut = sessionContext.getUserTransaction( );
ut.begin( );
//here I'm calling DB access etc: result = blabla....
ut.rollback( );
return result;
}
catch( Throwable t )
{
if( ut != null )
ut.rollback( );
SLog.error( t );
throw ( t instanceof Exception ) ? (Exception) t : new Exception( t );
}