Results 1 to 4 of 4

Thread: How to use WebSphereUowTransactionManager??

  1. #1
    Join Date
    Mar 2009
    Posts
    4

    Default How to use WebSphereUowTransactionManager??

    Hi i'm a new user, i'm using WebSphereUowTransactionManager and doesn't give errors, but the rollback is called but doesn't function.
    This is my code:
    context.xml
    Code:
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:aop="http://www.springframework.org/schema/aop"
    	xmlns:tx="http://www.springframework.org/schema/tx"
    	xmlns:jee="http://www.springframework.org/schema/jee"
    	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.5.xsd
    				http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
    				http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
            <!-- MySql JDBC Provider -->
    	<jee:jndi-lookup 
    		id="dataSource" 
    		jndi-name="jdbc/testJdbc"
    		cache="true" 
    		resource-ref="true" 
    		lookup-on-startup="false"
    		proxy-interface="javax.sql.DataSource" 		
    	/>
    		
    	<bean id="txManager"			class="org.springframework.transaction.jta.WebSphereUowTransactionManager">
    	</bean>
    
           <bean id="transactionServiceImpl"
    		class="it.iad.spring.FinanceServiceImpl">		
    		<property name="txManager" ref="txManager"/>
    		<property name="dataSource" ref="dataSource"/>
    	</bean>	
    
    	<tx:advice id="txAdvice" transaction-manager="txManager">
    		<tx:attributes>
    			<tx:method name="update*" propagation="REQUIRED" read-only="false" />
    			<tx:method name="*" />
    		</tx:attributes>
    	</tx:advice>
    
    	<aop:config>
    		<aop:pointcut id="financeServiceOperation"
    			expression="execution(* it.iad.spring.FinanceServiceImpl.*(..))" />
    		<aop:advisor advice-ref="txAdvice"
    			pointcut-ref="financeServiceOperation" />
    	</aop:config>
    
    </beans>
    My class FinanceServiceImpl
    Code:
    package it.iad.spring;
    
    import javax.sql.DataSource;
    
    import org.springframework.jdbc.core.JdbcTemplate;
    import org.springframework.transaction.jta.JtaTransactionManager;
    import org.springframework.transaction.jta.WebSphereUowTransactionManager;
    
    public class FinanceServiceImpl implements FinanceService{
    	
    	public void updateEmployees(String[] foo, String name) {	
    		String l = null;
    		for(int i=0;i < foo.length;i++)
    			template.update("update person set nome='"+name+"' where idPerson='"+foo[i]+"'");
    		l.charAt(12);
    	}
    
    	public void setDataSource(DataSource dataSource) {
    		this.dataSource = dataSource;		
    		template = new JdbcTemplate();
    		template.setDataSource(this.dataSource);
    	}
    
    	public void setTxManager(WebSphereUowTransactionManager txManager) {
    		this.txManager = txManager;		
    	}
    	
    	private DataSource dataSource;
    	private JdbcTemplate template;	
    	private WebSphereUowTransactionManager txManager;
    }
    In method updateEmployees i update some records on my db (MySql) and i throw a NullPointerException, the rollback is called but the changes on the db are permanet??
    Please help me to understand what's going wrong!!!

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    1) Make sure you use a correct datasource (which supports jta).
    2) You use MySQL make sure you use tables which support transactions (InnoDB, as MyISAM doesn't support transactions).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Mar 2009
    Posts
    4

    Default

    Quote Originally Posted by Marten Deinum View Post
    1) Make sure you use a correct datasource (which supports jta).
    I configure JDBC provider inside WebSphere and i used com.mysql.jdbc.jdbc2.optional.MysqlXADataSource.
    Quote Originally Posted by Marten Deinum View Post
    2) You use MySQL make sure you use tables which support transactions (InnoDB, as MyISAM doesn't support transactions).
    I use InnoDB as TableEngine and it's supports transactions!!!
    I try the same configuration with Oracle DBMS and the result is the same.
    However if i use org.springframework.jdbc.datasource.DataSourceTran sactionManager with property datasource like this:
    Code:
    <bean id="dataSource"
    		class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">		
    		<property name="driverClassName" value="com.mysql.jdbc.Driver" />
    		<property name="url" value="jdbc:mysql://localhost/test" />
    		<property name="username" value="miausername" />
    		<property name="password" value="miapassword" />
    	</bean>
    
    <bean id="txManager"		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    		<property name="dataSource" ref="dataSource"/>
    	</bean>
    the rollback function works.
    How to use WebSphereUowTransactionManager????
    Last edited by neopiu79; May 6th, 2009 at 02:58 AM.

  4. #4
    Join Date
    Oct 2009
    Posts
    21

    Default

    Did you find an answer? I am still looking

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •