Atomikos Forum

Connections Closing After Transactions

We have recently added JTA support to an existing product and are using Atomikos as a JTA provider.  In addition, our stack consists of Spring + Hibernate + Tomcat + MySql.

We would like to use the connection pooling that's built in to the Atomikos data source and have configured the pooling properties in our Spring configuration file.  The problem is that the connections are being closed after every transaction instead simply being returned to the pool.  Consequently, the system is constantly closing and opening connections resulting in a huge performance hit.  Does anyone know how to fix this problem?

Thanks.

Our Spring configuration:

<bean id="userTransactionService" 
      class="com.atomikos.icatch.config.UserTransactionServiceImp" 
      init-method="init" destroy-method="shutdownForce">
        <constructor-arg>
            <!-- IMPORTANT: specify all Atomikos properties here -->
            <props>
                <prop key="com.atomikos.icatch.service">com.atomikos.icatch.standalone.UserTransactionServiceFactory</prop>
                <prop key="com.atomikos.icatch.default_jta_timeout">600000</prop>
                <prop key="com.atomikos.icatch.max_timeout">600000</prop>
            </props>
        </constructor-arg>
    </bean>

    <bean id="transactionManager"
        class="org.springframework.transaction.jta.JtaTransactionManager"
        p:userTransaction-ref="userTransaction" p:transactionManager-ref="atomikosTransactionManager" p:allowCustomIsolationLevels="true"/>

    <bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
        p:forceShutdown="false" p:startupTransactionService="false"/>
        
    <bean id="userTransaction" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="java:comp/UserTransaction"/>
    </bean>
   
        <bean id="mysqlXaDataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource">
        <property name="url" value=... />
        <property name="user" value=... />
        <property name="password" value=... />
        <property name="pinGlobalTxToPhysicalConnection" value="true" />
        <property name="cachePreparedStatements" value="true" />
        <property name="autoReconnectForConnectionPools" value="true" />
        <property name="useServerPreparedStmts" value="true" />
    </bean>

        <bean id="dataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean"
        depends-on="serverConfiguration">
        <property name="xaDataSource" ref="mysqlXaDataSource" />
        <property name="uniqueResourceName" value="xads" />
        <property name="minPoolSize"
            value="#{deploymentConfigurationHolder.isDevelopmentMode() ? '2' : '5'}" />
        <property name="maxPoolSize"
            value="#{deploymentConfigurationHolder.isDevelopmentMode() ? '10' : '50'}" />
        <property name="maintenanceInterval" value="300" />
        <property name="testQuery" value="select 1" />
    </bean>

        <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="exposeTransactionAwareSessionFactory" value="true" />
        <property name="dataSource" ref="dataSource" />
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
                <prop key="hibernate.hbm2ddl.auto">validate</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.format_sql">true</prop>
                <prop key="hibernate.jdbc.batch_size">10</prop>
                <prop key="hibernate.order_updates">true</prop>
                <prop key="hibernate.use_sql_comments">false</prop>
                <prop key="hibernate.connection.release_mode">auto</prop>
                <prop key="hibernate.transaction.auto_close_session">false</prop>
                <prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
                <prop key="hibernate.cache.use_second_level_cache">true</prop>
                <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
                <prop key="hibernate.cache.use_query_cache">true</prop>
                <prop key="hibernate.cache.provider_configuration_file_resource_path">classpath:ehcache.xml</prop>
                <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>
                <prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup
                </prop>
                <prop key="hibernate.current_session_context_class">jta</prop>
            </props>
        </property>
          </bean>
Tommer Wizansky Send private email
Tuesday, November 27, 2012
 
 
Hi,

What evidence do you have for what you are describing?

Thanks
Guy Pardon Send private email
Monday, December 10, 2012
 
 
Change hibernate.connection.release_mode to AFTER_TRANSACTION instead of AUTO, it worked for us.
wwang Send private email
Friday, March 08, 2013
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics