is it possible to have a non-xa data source with PooledDataSource?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

is it possible to have a non-xa data source with PooledDataSource?

elhanan
we simply have to LocalSessionFactoryBeans, and one of them is being called asynchronsly, and that seperate thread, i saw hiberntate is calling beginTransaction, now even though i initiallly configured that SessionBean to be jta'd, bitronix still complained that i needed to set allowLocalTransaction property.

i understand i can't use the app server's data sources , so i'm trying to minimize my dependencies on other os (like c3po)
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to have a non-xa data source with PooledDataSource?

Ludovic Orban
Administrator
Hibernate's beginTransaction() call does not start a JTA transaction. You really have to get a reference to the JTA UserTransaction object and call begin on that one to start the transaction. The allowLocalTransaction parameter serves as a safeguard here: when the connection pool complains that you should enable it this means you're not working with JTA transactions.
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to have a non-xa data source with PooledDataSource?

elhanan
but i've seen that beginTransaction the it calls getTransactionFactory which is hibernate JtaTransactionTransaction, so eventually i did get a a jta transaction
Ludovic Orban wrote
Hibernate's beginTransaction() call does not start a JTA transaction. You really have to get a reference to the JTA UserTransaction object and call begin on that one to start the transaction. The allowLocalTransaction parameter serves as a safeguard here: when the connection pool complains that you should enable it this means you're not working with JTA transactions.
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to have a non-xa data source with PooledDataSource?

Ludovic Orban
Administrator
If you get an exception saying that you forgot to enable allowLocalTransactions this means you haven't started a JTA transaction, period.

Maybe Hibernate's transaction API has some hooks to call the JTA API and if they don't work that probably means you've mis-configured Hibernate. Please don't forget that using the Hibernate transaction API isn't such a good idea: even the Hibernate team recommends against it.
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to have a non-xa data source with PooledDataSource?

elhanan
they do, i'm calling hibernate's JTA transaction which inside it get lookup for userTransaction.

Ludovic Orban wrote
If you get an exception saying that you forgot to enable allowLocalTransactions this means you haven't started a JTA transaction, period.

Maybe Hibernate's transaction API has some hooks to call the JTA API and if they don't work that probably means you've mis-configured Hibernate. Please don't forget that using the Hibernate transaction API isn't such a good idea: even the Hibernate team recommends against it.
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to have a non-xa data source with PooledDataSource?

Ludovic Orban
Administrator
Let me emphasize this:

If you get an exception saying that you forgot to enable allowLocalTransactions this means a JTA transaction hasn't started, period.
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to have a non-xa data source with PooledDataSource?

elhanan
i understood that from the begining, which really had me worried
becouse i run in standalone mode, and it worked, which has me worried becouse i don't know why it's not working while it's running in a container.

this whole thing started becouse when we tried to use jboss jta (from jboss version 3.2.5) under certain conditions we got a timed out transaction, we never understood why.  can you tell me how it's bitronix checks to see if it's inside a jta transaction?

Ludovic Orban wrote
Let me emphasize this:

If you get an exception saying that you forgot to enable allowLocalTransactions this means a JTA transaction hasn't started, period.
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to have a non-xa data source with PooledDataSource?

Ludovic Orban
Administrator
The allowLocalTransactions check is done with internal API, it checks that you called UserTransaction.begin(). If BTM started up fine, there is no way this check can be wrong, it's too trivial.

On the other hand that's quite some new info that you got BTM running standalone and that it fails in an application server. I bet the problem is how you configured Hibernate to lookup the TX manager in JNDI.

What application server are you trying to use ? JBoss 3.2.x ? How did you configure Hibernate's TransactionManagerLookupFactory ?

I suggest you to check this thread as it contains very useful information about the way JNDI should be configured in Hibernate: http://www.nabble.com/Hibernate-JTATransactionFactory-and-BTMTransactionManagerLookup-td21706680.html#a21712765

Reply | Threaded
Open this post in threaded view
|

Re: is it possible to have a non-xa data source with PooledDataSource?

elhanan
i didn't set lookupFactory it's configured via spring, the localSessionFactory bean has a property which points the the actuall bitornix bean (the same one spring's jtaTransactionManager's properties of userTransaction and TransactionManager properties point to).

so there is no need to look them up.


Ludovic Orban wrote
The allowLocalTransactions check is done with internal API, it checks that you called UserTransaction.begin(). If BTM started up fine, there is no way this check can be wrong, it's too trivial.

On the other hand that's quite some new info that you got BTM running standalone and that it fails in an application server. I bet the problem is how you configured Hibernate to lookup the TX manager in JNDI.

What application server are you trying to use ? JBoss 3.2.x ? How did you configure Hibernate's TransactionManagerLookupFactory ?

I suggest you to check this thread as it contains very useful information about the way JNDI should be configured in Hibernate: http://www.nabble.com/Hibernate-JTATransactionFactory-and-BTMTransactionManagerLookup-td21706680.html#a21712765
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to have a non-xa data source with PooledDataSource?

Ludovic Orban
Administrator
There definitely is something wrong in one of your configuration files: Hibernate isn't starting JTA transactions, at least not on BTM: it might use you application server's TM instead.

Instead of asserting how things are supposed to be working I would advise you to check what's really happening under the hood. Hibernate needs a reference to BTM one way or another and it doesn't get it. How does your Spring config gives that reference to Hibernate ? That's what you have to figure out.
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to have a non-xa data source with PooledDataSource?

elhanan
and now the plot thickens, i've disabled localTransactions on all the bm data sources, and now i get
11:14:33,212 ERROR [TxInterceptorBMT] Application error: BMT stateless bean ConfigurationServiceEjb should complete transactions before returning (ejb1.1 spec, 11.6.1)

when i'm trying to bring up my server.
Ludovic Orban wrote
There definitely is something wrong in one of your configuration files: Hibernate isn't starting JTA transactions, at least not on BTM: it might use you application server's TM instead.

Instead of asserting how things are supposed to be working I would advise you to check what's really happening under the hood. Hibernate needs a reference to BTM one way or another and it doesn't get it. How does your Spring config gives that reference to Hibernate ? That's what you have to figure out.