Atomikos Forum

REQUIRES_NEW is not commited

Hi Atomikos,

i have the following configuration:
@Configuration
@EnableTransactionManagement
public class AtomikosConfig {

    @DependsOn({ "userTransaction", "atomikosTransactionManager" })
    @Bean(name = "transactionManager")
    public PlatformTransactionManager jtaTransactionManager() throws SystemException {
        JtaTransactionManager jtaTransactionManager = new JtaTransactionManager();
        jtaTransactionManager.setTransactionManager(atomikosTransactionManager());
        jtaTransactionManager.setUserTransaction(userTransaction());
        jtaTransactionManager.setAllowCustomIsolationLevels(true);

        return jtaTransactionManager;
    }

    @DependsOn("userTransaction")
    @Bean(name= "atomikosTransactionManager", initMethod = "init", destroyMethod = "close")
    public TransactionManager atomikosTransactionManager() {
        final UserTransactionManager userTransactionManager = new UserTransactionManager();
        userTransactionManager.setForceShutdown(false);
        return userTransactionManager;
    }

    @DependsOn("userTransactionServiceImp")
    @Bean(name = "userTransaction")
    public UserTransaction userTransaction() throws SystemException {
        final UserTransactionImp userTransactionImp = new UserTransactionImp();
        userTransactionImp.setTransactionTimeout(120);
        return userTransactionImp;
    }

    @Bean(name="userTransactionServiceImp", destroyMethod = "shutdownForce")
    public UserTransactionServiceImp userTransactionServiceImp() {
        final UserTransactionServiceImp srv = new UserTransactionServiceImp();

        /** default82df.html?community.6.1950.6 **/
        final Properties properties = new Properties();
        properties.setProperty("com.atomikos.icatch.enable_logging", "false");

        srv.init(properties);
        return srv;
    }
}

Datasource:
    @Bean(name = "datasource1")
    @Primary
    public DataSource orchZvsDataSource() throws SQLException {
        final OracleXADataSource oracleXADataSource = new OracleXADataSource();
        oracleXADataSource.setUser(datasource1.getUsername());
        oracleXADataSource.setPassword(datasource1.getPassword());
        oracleXADataSource.setURL(datasource1.getConnectionUrl());

        final AtomikosDataSourceBean atomikosDataSourceBean = new AtomikosDataSourceBean();
        atomikosDataSourceBean.setXaDataSource(oracleXADataSource);
        atomikosDataSourceBean.setMaxPoolSize(datasource1.getMaxPoolSize());
        atomikosDataSourceBean.setMinPoolSize(datasource1.getMinPoolSize());
        atomikosDataSourceBean.setMaxIdleTime(datasource1.getMaxIdleTime());

        return atomikosDataSourceBean;
    }

    @Bean(name = "datasource2")
    public DataSource prismaDataSource() throws SQLException {
        final OracleXADataSource oracleXADataSource = new OracleXADataSource();
        oracleXADataSource.setUser(datasource2.getUsername());
        oracleXADataSource.setPassword(datasource2.getPassword());
        oracleXADataSource.setURL(datasource2.getConnectionUrl());

        final AtomikosDataSourceBean atomikosDataSourceBean = new AtomikosDataSourceBean();
        atomikosDataSourceBean.setXaDataSource(oracleXADataSource);
        atomikosDataSourceBean.setMaxPoolSize(datasource2.getMaxPoolSize());
        atomikosDataSourceBean.setMinPoolSize(datasource2.getMinPoolSize());
        atomikosDataSourceBean.setMaxIdleTime(datasource2.getMaxIdleTime());
        return atomikosDataSourceBean;
    }

JPAConfiguration:
    @Override
    protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
        EclipseLinkJpaVendorAdapter adapter = new EclipseLinkJpaVendorAdapter();
        return adapter;
    }

    @Override
    protected Map<String, Object> getVendorProperties() {
        HashMap<String, Object> result = new HashMap<>();
        result.put("eclipselink.weaving", "false");
        result.put("eclipselink.cache.shared.default", "false");
        result.put("javax.persistence.transactionType", "JTA");
        result.put("eclipselink.orm.validate.schema", "true");
        result.put("javax.persistence.sharedCache.mode", "ENABLE_SELECTIVE");
        result.put("eclipselink.target-server", "com.atomikos.eclipselink.platform.AtomikosPlatform");
        return result;
    }

Dependencies:
* spring-boot 1.4.0
* eclipselink 2.6.3

My problem is by REQUIRES_NEW transaction is the new transaction at end of method not commited. I found that there isn't any participant in Coordinator. I actually don't find where is the problem.

Thank you for your support!
Grégory Neuhaus Send private email
Friday, October 27, 2017
 
 
I found the problem:

Missing @DependsOn("transactionManager") in DataSourceConfig and JPAConfiguration.

Spring has made a new instance of UserTransactionServiceImpl before the initialisation of beans in AtomikosConfig.
Grégory Neuhaus Send private email
Friday, October 27, 2017