Atomikos Forum

Postgress XA, spring 4, eclipselink

Hi, I have a war application deployed on jetty and using atomikos 3.9.3, spring 4, eclipselink 2.5.2 (with static waving) and Postgress XA driver 9.2-1002-jdbc4. From a spring @Controller class I only call this method:
@Transactional
public void dummyUpdate() {
    AppConfig appConfig = entityManager.find(AppConfig.class, 1);
    appConfig.setValue(String.valueOf(System.currentTimeMillis()));
}
Although no rollback log message occur (see atomikos log below) the database remains unchanged. When using jboss's transaction manager & usertransaction & datasourse through jndi the database is changed.

What's the problem with my atomikos configuration ?

The spring configuration is:

<bean id="entityManager" depends-on="dataSource"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="jtaDataSource" ref="dataSource" />
    <property name="packagesToScan" value="ro.uti.sags.stoservices.persistence" />
    <property name="persistenceUnitName" value="sto" />
    <property name="persistenceProvider">
        <bean class="org.eclipse.persistence.jpa.PersistenceProvider"/>
    </property>
    <property name="jpaPropertyMap" ref="jpaPropertyMap"/>
    <property name="jpaVendorAdapter" ref="jpaVendorAdapter"/>
    <property name="jpaDialect">
        <bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />
    </property>
</bean>

<bean id="setMyAtomikosSystemProps"
      class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <property name="targetObject">
        <!-- System.getProperties() -->
        <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
            <property name="targetClass" value="java.lang.System" />
            <property name="targetMethod" value="getProperties" />
        </bean>
    </property>
    <property name="targetMethod" value="putAll" />
    <property name="arguments">
        <!-- The new Properties -->
        <util:properties>
            <!--<prop key="com.atomikos.icatch.file">/etc/myapp/jta.properties</prop>-->
            <prop key="com.atomikos.icatch.no_file">true</prop>
            <prop key="com.atomikos.icatch.hide_init_file_path">true</prop>
            <prop key="com.atomikos.icatch.service">
                com.atomikos.icatch.standalone.UserTransactionServiceFactory
            </prop>
        </util:properties>
    </property>
</bean>

<bean id="userTransactionService" depends-on="setMyAtomikosSystemProps"
      class="com.atomikos.icatch.config.UserTransactionServiceImp"
      init-method="init" destroy-method="shutdownForce">
</bean>

<!--
     Construct Atomikos UserTransactionManager,
     needed to configure Spring
-->
<bean id="atomikosTransactionManager" depends-on="userTransactionService"
      class="com.atomikos.icatch.jta.UserTransactionManager"
      init-method="init" destroy-method="close">
    <!-- IMPORTANT: disable startup because the userTransactionService above does this -->
    <property name="startupTransactionService" value="false"/>
    <!--
         when close is called,
         should we force transactions to terminate or not?
      -->
    <property name="forceShutdown" value="false" />
</bean>

<!--
     Also use Atomikos UserTransactionImp,
     needed to configure Spring
-->
<bean id="atomikosUserTransaction" depends-on="userTransactionService"
      class="com.atomikos.icatch.jta.UserTransactionImp">
    <property name="transactionTimeout" value="300" />
</bean>

<!--
  Configure the Spring framework to use JTA transactions from Atomikos
-->
<bean id="transactionManager" depends-on="userTransactionService"
      class="org.springframework.transaction.jta.JtaTransactionManager">
    <property name="transactionManager" ref="atomikosTransactionManager" />
    <property name="userTransaction" ref="atomikosUserTransaction" />
</bean>

<bean id="dataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean"
        init-method="init" destroy-method="close">
    <property name="xaDataSourceClassName" value="org.postgresql.xa.PGXADataSource"/>
    <property name="minPoolSize" value="1"/>
    <property name="maxPoolSize" value="5"/>
    <property name="xaProperties">
        <props>
            <prop key="user">${db.username}</prop>
            <prop key="password">${password}</prop>
            <prop key="databaseName">${databaseName}</prop>
            <prop key="serverName">${serverName}</prop>
        </props>
    </property>
    <property name="UniqueResourceName" value="sto-xa-db"/>
</bean>

The atomikos log:
...
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] Coordinator 172.20.19.7.tm0005200001 : stopping timer...
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] Coordinator 172.20.19.7.tm0005200001 : disposing statehandler TERMINATED...
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] Coordinator 172.20.19.7.tm0005200001 : disposed.
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] getCompositeTransaction() returning NULL!
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] getCompositeTransaction() returning NULL!
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] Coordinator 172.20.19.7.tm0005400001 entering state: ACTIVE
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] (1.5) executing task: com.atomikos.timing.PooledAlarmTimer@f5b3e61
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] Creating composite transaction: 172.20.19.7.tm0005400001
17 Jul 16:36 [INFO ] [logging.Slf4jLogger.logInfo] createCompositeTransaction ( 300000 ): created new ROOT transaction with id 172.20.19.7.tm0005400001
17 Jul 16:36 [DEBUG] [misc.AppConfigCtrl.dummyUpdate] BEGIN dummyUpdate
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] getCompositeTransaction() returning NULL!
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] getCompositeTransaction() returning NULL!
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] Coordinator 172.20.19.7.tm0005500001 entering state: ACTIVE
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] (1.5) executing task: com.atomikos.timing.PooledAlarmTimer@4fb83a7a
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] Creating composite transaction: 172.20.19.7.tm0005500001
17 Jul 16:36 [INFO ] [logging.Slf4jLogger.logInfo] createCompositeTransaction ( 300000 ): created new ROOT transaction with id 172.20.19.7.tm0005500001
17 Jul 16:36 [DEBUG] [config.AppConfigService.dummyUpdate_aroundBody0] AppConfig{id=1, name='dummy name', value='1405604218733'}
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] getCompositeTransaction()  returning instance with id 172.20.19.7.tm0005500001
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] getCompositeTransaction()  returning instance with id 172.20.19.7.tm0005500001
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] getCompositeTransaction()  returning instance with id 172.20.19.7.tm0005500001
17 Jul 16:36 [INFO ] [logging.Slf4jLogger.logInfo] commit() done (by application) of transaction 172.20.19.7.tm0005500001
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] Coordinator 172.20.19.7.tm0005500001 entering state: COMMITTING
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] Coordinator 172.20.19.7.tm0005500001 entering state: TERMINATED
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] Coordinator 172.20.19.7.tm0005500001 : stopping timer...
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] Coordinator 172.20.19.7.tm0005500001 : disposing statehandler TERMINATED...
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] Coordinator 172.20.19.7.tm0005500001 : disposed.
17 Jul 16:36 [DEBUG] [misc.AppConfigCtrl.dummyUpdate] END dummyUpdate
17 Jul 16:36 [INFO ] [logging.Slf4jLogger.logInfo] AtomikosDataSoureBean 'sto-xa-db': getConnection ( null )...
17 Jul 16:36 [INFO ] [logging.Slf4jLogger.logInfo] AtomikosDataSoureBean 'sto-xa-db': init...
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] getCompositeTransaction() returning NULL!
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] an AtomikosXAPooledConnection with a SessionHandleState with 0 context(s): updating last time acquired
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] an AtomikosXAPooledConnection with a SessionHandleState with 0 context(s): no test query, skipping test
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] an AtomikosXAPooledConnection with a SessionHandleState with 0 context(s): creating connection proxy...
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] a SessionHandleState with 0 context(s): notifySessionBorrowed
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] a TransactionContext: changing to state com.atomikos.datasource.xa.session.NotInBranchStateHandler@25e08d8c
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] getCompositeTransaction() returning NULL!
17 Jul 16:36 [INFO ] [logging.Slf4jLogger.logInfo] atomikos connection proxy for Pooled connection wrapping physical connection org.postgresql.jdbc4.Jdbc4Connection@3d08b17b: calling toString...
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] atomikos connection proxy for Pooled connection wrapping physical connection org.postgresql.jdbc4.Jdbc4Connection@3d08b17b: toString returning Pooled connection wrapping physical connection org.postgresql.jdbc4.Jdbc4Connection@3d08b17b
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] an AtomikosXAPooledConnection with a SessionHandleState with 1 context(s): returning proxy Pooled connection wrapping physical connection org.postgresql.jdbc4.Jdbc4Connection@3d08b17b
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] atomikos connection pool 'sto-xa-db': got connection from pool
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] atomikos connection pool 'sto-xa-db': current size: 0/1
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] getCompositeTransaction() returning NULL!
17 Jul 16:36 [INFO ] [logging.Slf4jLogger.logInfo] atomikos connection proxy for Pooled connection wrapping physical connection org.postgresql.jdbc4.Jdbc4Connection@3d08b17b: calling toString...
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] atomikos connection proxy for Pooled connection wrapping physical connection org.postgresql.jdbc4.Jdbc4Connection@3d08b17b: toString returning Pooled connection wrapping physical connection org.postgresql.jdbc4.Jdbc4Connection@3d08b17b
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] AtomikosDataSoureBean 'sto-xa-db': returning Pooled connection wrapping physical connection org.postgresql.jdbc4.Jdbc4Connection@3d08b17b
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] getCompositeTransaction() returning NULL!
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] atomikos connection proxy for Pooled connection wrapping physical connection org.postgresql.jdbc4.Jdbc4Connection@3d08b17b: notifyBeforeUse a SessionHandleState with 1 context(s)
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] getCompositeTransaction() returning NULL!
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] a SessionHandleState with 1 context(s): checking XA context for transaction null
17 Jul 16:36 [DEBUG] [logging.Slf4jLogger.logDebug] a TransactionContext: changing to state null
...
adrian Send private email
Thursday, July 17, 2014
 
 
Also I use the postgresql configuration:
max_prepared_transactions = 100
max_connections = 100
adrian Send private email
Thursday, July 17, 2014
 
 
There is a transaction all right, but it is committed before the database access happens. You might want to check your transaction demarcation in your application.
Guy Pardon Send private email
Saturday, July 26, 2014
 
 

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

Other recent topics Other recent topics