Hi,
I am developing a standalone Java application using Oracle. In order to have distributed transaction, I looked up a JTA transaction manager from WebLogic server and bind the data source to it. Shown below is the configuration:
<bean id="dataSourceAbstract" class="javax.sql.DataSource" abstract="true">
<property name="driverClassName">
<value>${jdbc.driverClassName}</value>
</property>
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
lazy-init="true" parent="dataSourceAbstract">
</bean>
<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTran sactionManager">
<property name="jndiTemplate">
<ref bean="jndiTemplate" />
</property>
</bean>
<bean id="txProxyTemplate" abstract="true"
class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="customerContractCache" parent="txProxyTemplate" singleton="true">
<property name="target">
<bean class="foo.Test">
<property name="clientManager">
<ref bean="clientManager" />
</property>
</property>
</bean>
<bean id="clientManager" parent="txProxyTemplate" singleton="true">
<property name="target">
<bean class="foo.clientManagerImpl">
<property name="clientDAO">
<ref bean="clientDAO" />
</property>
</property>
</bean>
<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClient FactoryBean">
<property name="configLocation">
<value>
classpath:/foo/sql-map-config.xml
</value>
</property>
</bean>
<bean id="clientDAO"
class="foo.ClientDAOImpl">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="sqlMapClient">
<ref bean="sqlMapClient" />
</property>
</bean>
However, I found that transaction is committed each time function in foo.Test is executed. Even thought a RuntimeException was thrown intentionally at the end of a function, transaction is not rollback.
I would like to know what's wrong with the configuration?
Thanks.
Regards,
Koala Lam


Reply With Quote
