users@glassfish.java.net

Re: how to obtain a TransactionManager in a servlet?

From: Sanjeeb Kumar Sahoo <Sanjeeb.Sahoo_at_Sun.COM>
Date: Fri, 20 Apr 2007 21:21:32 +0530

AFAIK, you can obtain a reference to TransactionManager by looking up in
JNDI using a vendor *specific* name. In GlassFish, the
TransactionManager is bound to java:appserver/TransactionManager in JNDI.

But that interface is *not* designed for application developers. Can't
you use /UserTransaction.getStatus()/ to see if there is already
transaction started in the thread stack or not?

Thanks,
Sahoo
legolas wood wrote:
> Hi,
> Is it impossible to get TranactionManager in a servlet or it is
> meaningless?
>
> I thought TranactionManager can help us to see whether we are inside a
> UserTransaction or not.
> For example objectA.methodA calls objectB.methodB and it call
> objectC.methodC.
> Now i want to know wheter any of methodA or methodB start a
> userTransaction or not.
> I think i can do it using TransactionManager.
>
>
> Thanks
>
>
>
> Sanjeeb Kumar Sahoo wrote:
>> Hi Legolas,
>>
>> Instead of injecting TranactionManager, inject a UserTransaction
>> object like this:
>> @Resource private javax.transaction.UserTranaction utx;
>>
>> Now you can use utx to control transaction boundaries.
>>
>> Thanks,
>> Sahoo
>>
>> legolas wood wrote:
>>> Hi
>>> Thank you for reading my post
>>> I have tried to obtain a transaction manager using
>>>
>>> @Resource TransactionManager txm;
>>>
>>> and it does not work, can you tell me how i can create a
>>> TranasactionManager object in my servlet?
>>>
>>> Thanks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>