1 Reply Latest reply: Sep 3, 2014 2:31 AM by user10918815 RSS

    Transactions in OSGi

    user10918815

      I am building a web application which uses a number of OSGi modules deployed in the WebLogic OSGi during the deployment of my application. In order to be able to read/write to a DB from my OSGi services I have created a datasource in WebLogic for which I am able to inject an EntityManager in my OSGi services via blueprint:

       

      <bean id="TestServiceImpl" class="com.test.impl.TestServiceImpl">

              <jpa:context property="em" unitname="mypu" />

              <tx:transaction method="*" value="Required" />

      </bean>

      <service id="TestService" ref="TestServiceImpl" interface="com.test.api.TestService" />

       

      My problem is that although I have also included tx:transaction in my blueprint.xml and deployed Aries transaction in the OSGi no transaction is created for my OSGi service methods.

       

      After some digging I came to the conclusion that the problem is that Aries transaction listens for implementations of javax.sql.XADataSource which it then wraps in a XADataSourceEnlistingWrapper and exposes as javax.sql.DataSource in order to be used by my bundle. In my case however the datasource WebLogic creates is a weblogic.jdbc.common.internal.RmiDataSource which does not implement javax.sql.XADataSource so Aries doesn't pick it up.

       

      Is my understanding of the problem correct? What do I need to do in order to have XA transactions in WebLogic's OSGi?