Announcement Announcement Module
Collapse
No announcement yet.
How to implement WebSphereUowTransactionManager Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to implement WebSphereUowTransactionManager

    Hi,

    Please find the details below.

    Problem:
    I am getting an exception while using WebSphereUowTransactionManager. Here is the exception details:


    Cannot resolve reference to bean 'txManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'txManager_UOW' defined in class path resource [/spring.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org/springframework/transaction/jta/WebSphereUowTransactionManager.initUserTransaction AndTransactionManager()V

    I ran my applcation in the debug mode and found that control is reaching till the call to initUserTransactionAndTransactionManager() in org.springframework.transaction.jta.WebSphereUowTr ansactionManager but then instead of going into this method it throws above exception. The initUserTransactionAndTransactionManager() is the protected method in the superclass (org.springframework.transaction.jta.JtaTransactio nManager) of WebSphereUowTransactionManager.


    Other Details: Versions
    I am using Spring-Framework-2.5.2 and RSA 7.0.0.3 (with WAS version6.1.0.9).

    Code:
    Here is the relevant snippet from the the spring configuration file
    Code:
    <bean id="txManager_UOW" class="org.springframework.transaction.jta.WebSphereUowTransactionManager" />
    
    <alias name="txManager_UOW" alias="txManager" />
    
    <bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">
          <property name="transactionManager" ref="txManager" />
          <property name="transactionAttributes">
          <props>
                    <prop key="insert*">PROPAGATION_REQUIRED,-DomainDataDAOException
                   </prop>
                   <prop key="update*">PROPAGATION_REQUIRED,-DomainDataDAOException
                   </prop>
    	  <prop key="retrieve*">PROPAGATION_REQUIRED, readOnly, -DomainDataDAOException
                   </prop>
         </props>
        </property>
    </bean>
    
    <bean id="transactionTestDAO" parent="baseTransactionProxy">
    	<property name="target" ref="transactionTestDAOImpl" />
    </bean>
              
    <bean id="transactionTestDAOImpl" class="com.nm.ltc.domain.transaction.test.TransactionTestDAOImpl">
                <property name="sqlMapClient">
                            <ref bean="sqlMapClient" />
    	</property>
    </bean>
    Any help on this would be much appreciated.

    Thanks,
    Ritwick
    Last edited by Ritwick; Jun 3rd, 2008, 07:38 PM.

  • #2
    I expect that you are mixing spring versions. Make sure you only have one spring.jar or the correct spring-[module].jar in your classpath.

    Comment


    • #3
      Thanks Marten. It was the same issue infact.

      Actually this transaction manager works fine for a single datasource, but fails in case we have multiple datasources. I am using two sybase datasources installed on two different boxes. Here is the description of the problem:

      The initiated transaction keeps hold of the first connection and substitutes it for every connection requested thereafter. Obviously the first connection will not work with any datasource but the one it is connected to. Thinking from transaction’s perspective it should have a reference to the first connection to rollback in case the query for second datasource fails. So the clever transaction is playing safe from its point of view. And thus I am not able to connect to the second datasource.

      Both of the databse get updated if I don't use the transaction manager.
      There should be some way to enable the request for the new connection instead of picking it up from the transactions cache reference.

      Here is code that i am using to fire the queries from sql maps (I am using iBATIS with Spring).

      Code:
      private Object doInsert(String theSQL, TestData testData, String dataSource) throws DomainDataDAOException {
                   Connection conn = null;
      	SqlMapSession session = null;
      	try {
      		// dataSource will have different values for different datasources. Refer to handbook for more details.
      		DataSourceContextHolder.setDataSourceType(dataSource);
      		conn = getSqlMapClientTemplate().getSqlMapClient().getDataSource().getConnection();
      		session = getSqlMapClientTemplate().getSqlMapClient().openSession(conn);
      		return ((Object) session.insert(theSQL, testData));
      	} catch (SQLException exSQLException) {
      	             throw new DomainDataDAOException("SQLException has occured while fetching the data.", exSQLException);
      		} catch (SqlMapException exSqlMapException) {
      			throw new DomainDataDAOException(	"There seems to be a type mismatch for the columns in sqlmap"+ 
                                             "and the model for the table.", exSqlMapException);
      		} catch (Exception ex) {
      			throw new DomainDataDAOException("Exception occured while fetching the data.", ex);
      		} finally {
      			DataSourceContextHolder.clearDataSourceType();
      			if (session != null)
      				session.close();
      			try {
      				if (conn != null)
      					conn.close();
      			} catch (SQLException exSQLException) {
      				throw new DomainDataDAOException(
      						"SQLException has occured while closing the database connection.",
      						exSQLException);
      			}
      		}
      	}
      Could you please suggest the solution for this.

      Thanks,
      Ritwick
      Last edited by Ritwick; Jun 4th, 2008, 07:41 PM.

      Comment


      • #4
        1) Don't do resource management yourself. You use the template then also use its methods.
        2) Use XA capable datasource
        3) Use JNDI registered datasource not a local (spring configured datasource)

        Comment


        • #5
          There seems to be some DTM related issue with the server. We are working on that.
          Thanks for your help on this Marten.

          Comment

          Working...
          X