Announcement Announcement Module
No announcement yet.
JTA Transaction Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JTA Transaction

    I am using spring integration.I am reading messahe from MQ and mean while for audit purpose i am recording each message read in datbase.If there is any issue then messahe should go back to MQ and entry should be removed from databse.I used the below code but getting exception

    Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'ConnectionFactory' defined in class path resource [spring-config.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: com.atomikos.icatch.system.Configuration.isInfoLog gingEnabled()Z
    at AutowireCapableBeanFactory.initializeBean(Abstract
    at AutowireCapableBeanFactory.doCreateBean(AbstractAu
    <bean id="connectionFactory" class="org.apache.activemq.ActiveMQXAConnectionFactory">
    		<property name="brokerURL">
        <tx:annotation-driven transaction-manager="myTxManager1" /> 
     <!--    Distributed transaction -->
     <bean id="AtomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
    init-method="init" destroy-method="close"> 
    <property name="forceShutdown" value="false" />
     <bean id="AtomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">
      <property name="transactionTimeout" value="300" /> 
      <bean id="myTxManager1"   class="org.springframework.transaction.jta.JtaTransactionManager">  
        <property name="transactionManager" ref="AtomikosTransactionManager" />   
       <property name="userTransaction" ref="AtomikosUserTransaction" />
        <bean id="ConnectionFactory"   class="com.atomikos.jms.AtomikosConnectionFactoryBean"               
     init-method="init" destroy-method="close">       <property name="uniqueResourceName" value="amq1" />
               <property name="xaConnectionFactory" ref="connectionFactory" />             
     <bean id="ds" class="com.atomikos.jdbc.nonxa.NonXADataSourceBean">
      	<property name="uniqueResourceName" value="ds"/>
       <property name="driverClassName" value="com.mysql.jdbc.Driver" />
      <property name="url" value="jdbc:mysql://localhost:3306/amit" /> 
      <property name="poolSize" value="20"/>
      <property name="connectionTimeout" value="10000"/>
      <property name="validatingQuery" value="select 1 from dual"/>
      <property name="testOnBorrow" value="true"/>
      <property name="user" value="root"/>
      <property name="password" value="amit"/>
      <!--    Distributed transaction Completed -->   
          <tx:advice id="transactionAdvice1" transaction-manager="myTxManager1" >
                <tx:method name="*" propagation="REQUIRED" isolation="READ_COMMITTED"
                    timeout="-1" read-only="false" rollback-for="java.lang.Exception"
                    no-rollback-for="NoTransactionException" />
    	<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    		<property name="connectionFactory" ref="connectionFactory" />
     <bean id="jdbctemplate" class="org.springframework.jdbc.core.JdbcTemplate">
      <property name="dataSource" ref="ds" /> 
         <int:channel id="input" />
    	 <int:channel id="fileOutPutChannel"></int:channel>
    	  <int:channel id="dbinputchannel" />
    		<jms:outbound-channel-adapter id="channel-to-mq"
    			channel="input" destination-name="amit1" />
    			id="mq-message-listner" channel="dbinputchannel"
    			destination-name="amit1" concurrent-consumers="10"  transaction-manager="myTxManager1" />

  • #2
    Well, he exception comes from bootstrapping Atomicos ConnectionFactory
    java.lang.NoSuchMethodError: com.atomikos.icatch.system.Configuration.isInfoLog gingEnabled()Z

    I am not sure why it is looking for this method and I don't have access to the source code, but may be you can look into that.


    • #3
      Please find attached the code base
      Attached Files


      • #4
        If you look at the Source code of Configuration the method isinfoLoggingEnabled is present in version 3.7.0

        Below is your classpath
        <classpathentry kind="lib" path="C:/WallGreens/Jars/atomikos-jars/transactions-3.2.3.jar"/>
        <classpathentry kind="lib" path="C:/WallGreens/Jars/atomikos-jars/transactions-api-3.2.3.jar"/>
        <classpathentry kind="lib" path="C:/WallGreens/Jars/atomikos-jars/atomikos-util-3.2.3.jar"/>
        <classpathentry kind="lib" path="C:/WallGreens/Jars/atomikos-jars/transactions-jta-3.2.3.jar"/>
        <classpathentry kind="lib" path="C:/WallGreens/Jars/atomikos-jars/transactions-jms-3.7.0.jar"/>
        <classpathentry kind="lib" path="C:/WallGreens/Jars/atomikos-jars/atomikos-transactions-jta.jar"/>
        <classpathentry kind="lib" path="C:/WallGreens/Jars/atomikos-jars/atomikos-transactions-jms.jar"/>
        <classpathentry kind="lib" path="C:/WallGreens/Jars/atomikos-jars/transactions-osgi-3.7.0.jar"/>
        Stick to using the same version of jars, use 3.7.0 or 3.2.3 version for all, do not mix them up.


        • #5
          =Amol Nayak;388047]If you look at the Source code of Configuration the method isinfoLoggingEnabled is present in version 3.7.0

          Below is your classpath

          Stick to using the same version of jars, use 3.7.0 or 3.2.3 version for all, do not mix them up.

          Now i am able to run the code but when there is exceptions it is not sending the message back to MQ.Although dabase entrie is getting rollback.
          Attachment [
          Attached Files


          • #6
            I am not an Atomikos expert but why are you using a Non XA Datasource if you want the MQ and Database to take part in the same transaction?

            Also enable debug level logs and check for yourself if you see something interesting and get an idea about the issue of why MQ's De queue of message is not happening as part of the transaction. For the transaction to rollback and put the message back on queue, the transaction context should be coming till your service activator (there would be other configurations too, will have to do more analysis for that).

            Going through the whole project can be confusing and time consuming for all, try to narrow down on important configs and parts of codes and post only the necessary ones.
            Last edited by Amol Nayak; Nov 16th, 2011, 03:08 AM.


            • #7
              Originally posted by Amol Nayak View Post
              I am not an Atomikos expert but why are you using a Non XA Datasource if you want the MQ and Database to take part in the same transaction?
              Hi Amol could you please provide me JTA setting in spring configuration(any JTA implementation) which i can run on my websphere .I was using Atomikos just to test it as standalone application.
              If you could provide me some better solution that will a great help.


              • #8
                I have not used a JTA transaction in standalone mode myself, but atomikos is popular choice. You can get some help online and go ahead with it.

                For using websphere you just need to set the JNDI name of your transaction manager on websphere while defining the JTATransactionManager in your spring config. If the JNDI name of the transaction manager is default one, you can set the autodetectTransactionManager to true and choose not to provide the JNDI name.
                See the javadocs of JTATransactionManager for more details.

                Please remember when you use these JNDI names, the application should be deployed on the application server, you can no longer run it in stand alone mode as the .

                Also create an XA Datasource for your database and an XAConnectionFactory for your MQ. Configuring Websphere MQ would be easy there, since this is a test application you are free to use any implementation.

                Does that answer your questions?
                Last edited by Amol Nayak; Nov 16th, 2011, 05:45 AM.