Hi all,

I have the following situation:

Serivce A (Annotated with @Transactional(propagation =
Propagation.REQUIRES_NEW){
   --> call Service B (Annotated with @Transactional(propagation =
Propagation.NESTED){
             do database access/update with hibernate template.
         }
   --> call Service C (Annotated with @Transactional(propagation =
Propagation.NESTED){
             do database access/update with hibernate template.
         }
}


The error message:
2007-02-13 16:40:19,703 ERROR CorrelatorScheduler_Worker-1
[ElementService.start:98] - <JTA implementation does not support nested
transactions; nested exception is javax.transaction.NotSupportedException:
Nested Transactions are not supported>
org.springframework.transaction.NestedTransactionNotSupportedException: JTA
implementation does not support nested transactions; nested exception is
javax.transaction.NotSupportedException: Nested Transactions are not
supported
Caused by: 
javax.transaction.NotSupportedException: Nested Transactions are not
supported
        at
org.apache.geronimo.transaction.manager.TransactionManagerImpl.begin(TransactionManagerImpl.java:172)
        at
org.apache.geronimo.transaction.manager.TransactionManagerImpl.begin(TransactionManagerImpl.java:167)
        at
org.springframework.transaction.jta.JtaTransactionManager.doJtaBegin(JtaTransactionManager.java:655)
        at
org.springframework.transaction.jta.JtaTransactionManager.doBegin(JtaTransactionManager.java:612)
        at
org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:430)
        at
org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:329)
        at
org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:255)
        at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:102)
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
        at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
        at $Proxy34.process(Unknown Source)
        at
br.com.cpqd.correlator.business.element.impl.ElementService.start(ElementService.java:81)


appcontext.xml
<beans
  xmlns="http://www.springframework.org/schema/beans";
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xmlns:tx="http://www.springframework.org/schema/tx";
  xsi:schemaLocation="
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd";>

    <!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> 
    <!-- enable the configuration of transactional behavior based on
annotations -->
    <!--
~~~~~~~~~~~~~============~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> 
    <tx:annotation-driven transaction-manager="transactionManager" />   

    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> 
    <!-- transactional AOP advice which can be used by AOP pointcuts --> 
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> 
    <tx:advice id="persistenceTxAdvice"
transaction-manager="transactionManager"> 
        <tx:attributes> 
            <!-- all methods starting with 'get' are read-only --> 
            <tx:method name="get*" read-only="true" /> 
            <!-- other methods use the default transaction settings (see
below) --> 
            <tx:method name="*" /> 
        </tx:attributes> 
    </tx:advice> 
    
    <bean id="jndi" class="org.apache.xbean.spring.jndi.DefaultContext">
        <property name="entries">
            <map>
                <entry key="java:/UserTransaction">
                        <ref bean="userTransaction"/>
                </entry>
             </map>
        </property>
     </bean>

    
  <!-- ###### Transaction manager ###### -->
  <bean id="userTransaction"
class="org.jencks.factory.TransactionManagerFactoryBean"/>

  <!-- ###### Connection Manager ###### -->
  <bean id="connectionManager"
class="org.jencks.factory.ConnectionManagerFactoryBean">
    <property name="transactionManager" ref="userTransaction"/>
  </bean>

  <!-- ###### JDBC Managed Connection Factory ###### -->
  <bean id="jdbcManagedConnectionFactory"
class="org.jencks.tranql.DataSourceMCF">
    <property name="driverName" value="${jdbc.driver}"/>
    <property name="url" value="${jdbc.url}"/>
    <property name="user" value="${jdbc.username}"/>
    <property name="password" value="${jdbc.password}"/>
  </bean>

  <!-- ###### JDBC Data Source ###### -->
  <bean id="xaDataSource"
class="org.jencks.factory.ConnectionFactoryFactoryBean">
    <property name="managedConnectionFactory"
ref="jdbcManagedConnectionFactory"/>
    <property name="connectionManager" ref="connectionManager"/>
  </bean>
    
        <bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager"
autowire="constructor">
        <constructor-arg>
                <bean class="org.jencks.factory.TransactionManagerFactoryBean" 
/>
        </constructor-arg>
        </bean>
    
    <!-- Spring Data Access Exception Translator Defintion -->
    <bean id="jdbcExceptionTranslator"
class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
      <property name="dataSource">
          <ref bean="xaDataSource" />
      </property>
    </bean>

    <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
      <property name="jtaTransactionManager"><ref
bean="userTransaction"/></property>
          <property name="jdbcExceptionTranslator"><ref
bean="jdbcExceptionTranslator" /></property>      
      <property name="dataSource"><ref bean="xaDataSource" /></property>
      <property name="schemaUpdate"><value>false</value></property>
      <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="show_sql">${hibernate.show.sql}</prop>
            <prop key="use_outer_join">true</prop>
            <prop key="default_lazy">false</prop>
            <prop key="hibernate.cache.use_query_cache">true</prop>
            <prop key="hibernate.cache.use_second_level_cache">true</prop>
            <prop
key="hibernate.cache.provider_class">org.hibernate.cache.TreeCacheProvider</prop>
            <prop
key="hibernate.bytecode.use_reflection_optimizer">true</prop>
            <prop
key="hibernate.connection.release_mode">after_transaction</prop>
            <prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
            <prop
key="hibernate.transaction.flush_before_completion">true</prop>
            <prop key="hibernate.transaction.auto_close_session">true</prop>
            <prop
key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>
            <prop
key="hibernate.current_session_context_class">thread</prop>
            <prop key="hibernate.jdbc.batch_size">1000</prop>
          </props>
      </property>

      <property name="annotatedClasses">
          <list>
                  .....
          </list>
      </property>
    </bean>


</beans>

Any Ideas?

Marcelo Bellezo

-- 
View this message in context: 
http://www.nabble.com/Spring%2BJencks%2BHibernate---Nested-Transactions-are-not-supported-tf3222584.html#a8950581
Sent from the jencks - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to