Hello,
I've been wrestling with this problem all afternoon; I've seen the various postings on this issue but nothing seems to be working. So here is one more instance of this classic problem.
First, my environment. I am running MySQL backend, using InnoDB database tables. I am using Spring 1.2. I am deploying a web application on Tomcat 5.0.23
Here is a snippet of my application context file:
I intentionally throw a RuntimeException in my method "saveRequest(...)" after saving an object to see a rollback, however it fails to rollback. This is what gets printed to the log file:Code:<beans> <!-- some bean declarations --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close"> <property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property> <property name="url"><value>jdbc:mysql://localhost/mydb</value></property> <property name="username"><value>root</value></property> <property name="password"><value>********</value></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"><ref bean="dataSource"/></property> <property name="mappingResources"> <list> <value>com/something/SomeObject.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">false</prop> <prop key="hibernate.max_fetch_depth">3</prop> <prop key="hibernate.connection.autocommit">false</prop> </props> </property> </bean> <bean id="hibernateTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"><ref bean="sessionFactory"/></property> </bean> <bean id="springHibernateDao" class="com.something.SpringHibernateDao"> <property name="sessionFactory"><ref bean="sessionFactory"/></property> </bean> <!-- some more bean declarations --> <bean id="serviceTarget" class="com.something.DefaultService"> <property name="maxAgeInDays"><value>365</value></property> <property name="idGenerator"><ref bean="idGenerator"/></property> </bean> <bean id="service" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"><ref bean="hibernateTransactionManager"/></property> <property name="target"><ref bean="serviceTarget"/></property> <property name="transactionAttributes"> <props> <prop key="saveRequest">PROPAGATION_REQUIRED, ISOLATION_READ_COMMITTED</prop> </props> </property> </bean> </beans>
The lines that get to me are the ones that says Winning rollback rule is: null and No relevant rollback rule found: applying superclass default. I don't understand what this output means. Why isn't it finding a winner?Code:2005-06-21 17:50:44,284 DEBUG [com.something.DefaultService] - <Throwing random exception> 2005-06-21 17:50:44,284 DEBUG [org.springframework.transaction.interceptor.RuleBasedTransactionAttribute] - <Applying rules to determine whether transaction should rollback on com.something.ServiceException: java.lang.RuntimeException: Viva la Bam!> 2005-06-21 17:50:44,284 DEBUG [org.springframework.transaction.interceptor.RuleBasedTransactionAttribute] - <Winning rollback rule is: null> 2005-06-21 17:50:44,284 DEBUG [org.springframework.transaction.interceptor.RuleBasedTransactionAttribute] - <No relevant rollback rule found: applying superclass default> 2005-06-21 17:50:44,284 DEBUG [org.springframework.transaction.interceptor.TransactionInterceptor] - <com.something.DefaultService.saveRequest threw throwable [com.something.ServiceException: java.lang.RuntimeException: Viva la Bam!] but this does not force transaction rollback> 2005-06-21 17:50:44,334 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - <Clearing transaction synchronization> 2005-06-21 17:50:44,334 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - <Removed value [org.springframework.orm.hibernate3.SessionHolder@3d0426] for key [org.hibernate.impl.SessionFactoryImpl@167f4bf] from thread [http-8080-Processor24]> 2005-06-21 17:50:44,334 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - <Removed value [org.springframework.jdbc.datasource.ConnectionHolder@5084c6] for key [org.springframework.jdbc.datasource.DriverManagerDataSource@381d92] from thread [http-8080-Processor24]>
Any help you can provide is greatly appreciated.
Sincerely,
Daniel



Reply With Quote