karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <alexander.sah...@brodos.de>
Subject Antw: Re: OSGi Transaction control fails with hibernate
Date Wed, 13 Sep 2017 09:59:56 GMT
Hi Tim,

I use a JPAEntityManagerProviderFactory (providerFactory) which I
inject as a service reference into my repository class. 
Furthermore, I inject a EntityManagerFactory (emf) into the repository
class as well as the TransactionControl (txControl).

The provider Factory is created by pax-jdbc (I use hibernate).

This provider factory is then used to get the Entity manager like
this:

EntityManager em = providerFactory.getProviderFor(emf,
null).getResource(txControl);

It fails giving an exception telling that transaction cannot be joined,
because it's not open.

The wrapping call is like this:
txControl.build()
			    .required(
					    () -> repo.store(article));

Best, Alexander.


>>> 
Hi Alexander,

Do you have a code example of how you’re obtaining and using the
EntityManager? There should be no usage of the OSGiJtaPlatform from the
tx-control XA JPA resource provider, which means that there’s either a
bug in the resource provider, or something is misconfigured. If you are
a member of the Aries user mailing list then that would be a better
place to continue this discussion.

Regards,

Tim



On 13 Sep 2017, at 09:21, Guillaume Nodet <gnodet@apache.org> wrote:

Fwiw, you should ask on the Aries mailing list, where tx-control is
developed.

I've recently worked on a new project called pax-transx which provides
an abstraction layer on top of transaction managers so that some
features can be accessed in a common way.  I think this should be used
in tx-control instead of wrapping the tm again and not being flexible.
Right now, tx-control uses its own instance of transaction manager and
there's no way around afaik, so you can't use the karaf transaction
feature if you want to use it.
Anyway, I'd gladly support you if you go to the aries mailing list to
raise this point !

2017-09-13 9:52 GMT+02:00 <alexander.sahler@brodos.de>:


Hello.

I'm trying to get tx-control with XA transactions running (local is
working). 
I found that tx-control opens a JTA transaction using
RecoveryWorkAroundTransactionManager (derived from geronimo's
TransactionManager Implementation) explicitly instead of using the
registered TransactionManager (aries in my case for karaf 4.0.9). When
hibernate EntityManager implementation tries to join the transaction it
fails because it uses the TransactionManager provided by OsgiJtaPlatform
(from hibernate-osgi) which is of course the one registered in osgi
ecosystem.

I think that the tx-control implementation has to use the
TransactionManager registered with OSGi.

Has anyone got that thing ever running?

Best Alexander.



-- 
------------------------
Guillaume Nodet



Mime
  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message