Announcement Announcement Module

Spring Dynamic Modules forum decommissioned in favor of Eclipse Gemini Blueprint

With the official first release of Eclipse Gemini Blueprint shipped, the migration of the Spring Dynamic Modules code base to the Eclipse Foundation, as part of the Gemini project, has been completed.

As such, this forum has been decommissioned in favour of the Eclipse Gemini forums.
See more
See less
Transaction not propagated between bundles (Service & DAO) Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transaction not propagated between bundles (Service & DAO)


    I have created a JPA project using EclipseLink JPA 1.x version and deployed in ServiceMix OSGI server 4.X running Apache Felix Server. The project consists of several bundles : model, dao and service layer. To define services as transactional, I have used the annotation @Transactional. Unfortunately, the transaction is not started and not committed when I call the method of my service (bundle Service). It works fine when @Transactional is defined in the bundle DAO.

    Remark : I use Spring DM 1.2. and Spring 2.5.6.SECO1

    Can someone tell me what I doing wrong (if this is the case) ?
    It should be interesting that the Petclinic example implements also a Service layer ;-)

    A. Bundle Service

    1) Class Service

    public class PersistenceImpl implements Persistence {

    private SapDocumentDAO sapDocumentDAO;

    public void save(@Body final FinishedTireDocument finishedTiredDocument, Exchange exch) {
    2) Spring

    <context:component-scan base-package=""/>
    <tx:annotation-driven transaction-manager="txManager" mode="aspectj"/>

    <!-- Get Transaction Manager from OSGI Services -->
    <osgi:reference id="txManager" interface="org.springframework.transaction.Platfor mTransactionManager" />

    <!-- Get DAO from OSGI Services -->
    <osgi:reference id="sapDocumentDAO" interface=" SapDocumentDAO" />

    <!-- Expose Persistence as a Service -->
    <osgi:service ref="sapService" interface=" istence" />

    B. Bundle DAO

    1) Class DAO

    public class SapDocumentDAOImpl implements SapDocumentDAO {

    private EntityManager em;

    public void setEntityManager(EntityManager em) {
    this.em = em;

    public SapDocumentDAOImpl() {
    // System.out.println(">>> SapDocumentDAOImpl instantiated");

    public void save(FinishedTireDocument finishedTiredDocument) {
    2) Spring

    <context:annotation-config />
    <context:component-scan base-package=" pl"/>

    <bean class=" enceAnnotationBeanPostProcessor" />
    <bean class="org.springframework.dao.annotation.Persiste nceExceptionTranslationPostProcessor"/>

    <!-- Can be used with a DataSource -->
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean">
    <property name="persistenceUnitName" value="sap" />
    <property name="jpaVendorAdapter" ref="jpaAdapter" />
    <property name="dataSource" ref="dataSource" />

    <!-- DataSource -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="username" value="sap"/>
    <property name="password" value="sap"/>
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    <property name="url" value="jdbc:mysql://localhost:3306/sapdb"/>

    <!-- EclipseLink adapter -->
    <bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.EclipseL inkJpaVendorAdapter">
    <property name="databasePlatform" value="org.eclipse.persistence.platform.database.M ySQLPlatform" />
    <property name="database" value="MYSQL" />

    <!-- Expose DAO as OSGI service -->
    <osgi:service ref="sapDocumentDAO" interface=" SapDocumentDAO"/>

    <!-- TransactionManager is required -->
    <bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionM anager">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
    <property name="dataSource" ref="dataSource"/>

    <!-- Expose TxManager/Template as OSGI Service -->
    <osgi:service ref="txManager" interface="org.springframework.transaction.Platfor mTransactionManager"/>

    Kind regards,