org.springframework.transaction.UnexpectedRollbackException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

    • org.springframework.transaction.UnexpectedRollbackException: JTA transaction unexpectedly rolled back (maybe due to a timeout); nested exception is bitronix.tm.internal.BitronixRollbackException: RuntimeException thrown during beforeCompletion cycle caused transaction rollback There's some of the configuration I'm using (please see github for all of it) @Bean public JPAConfig jpaConfig() throws Exception { Properties p = new Properties(); p.setProperty("hibernate.dialect", HSQLDialect.class.getName()); p.setProperty("hibernate.hbm2ddl.auto", "create-drop"); p.setProperty("hibernate.showsql", "true"); return new JPAConfig(p, datasource(), true, "com.kloudtek.ktspring"); } public DataSource datasource() throws Exception { PoolingDataSource dataSource = new PoolingDataSource(); dataSource.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource"); dataSource.setUniqueName("hsqldb"); dataSource.setMaxPoolSize(5); dataSource.setAllowLocalTransactions(true); dataSource.getDriverProperties().setProperty("driverClassName", "org.hsqldb.jdbcDriver"); dataSource.getDriverProperties().setProperty("url", "jdbc:hsqldb:mem:test?hsqldb.applog=3"); dataSource.getDriverProperties().setProperty("user", "sa"); dataSource.getDriverProperties().setProperty("password", "theSaPassword"); try (Connection connection = dataSource.getConnection()) { try (Statement st = connection.createStatement()) { st.execute("SET DATABASE EVENT LOG SQL LEVEL 3"); } } return dataSource; } @Bean public JPAParams jpaParams() { Properties p = new Properties(); p.setProperty("hibernate.current_session_context_class", "jta"); p.setProperty("hibernate.transaction.jta.platform", BitronixJtaPlatform.class.getName()); p.setProperty("hibernate.connection.autocommit", "false"); return new JPAParams(p); } @Bean(destroyMethod = "shutdown") public BitronixTransactionManager bitronixTransactionManager() { return TransactionManagerServices.getTransactionManager(); } @Bean public PlatformTransactionManager transactionManager() { return new JtaTransactionManager(bitronixTransactionManager(), bitronixTransactionManager()); } @Bean public LocalContainerEntityManagerFactoryBean entityManager() { LocalContainerEntityManagerFactoryBean entityManager = new LocalContainerEntityManagerFactoryBean(); if (config.isJtaDatasource()) { entityManager.setJtaDataSource(config.getDataSource()); } else { entityManager.setDataSource(config.getDataSource()); } Properties p = new Properties(); p.putAll(config.getJpaProperties()); if (jpaParamsList != null) { for (JPAParams jpaParams : jpaParamsList) { p.putAll(jpaParams.getProperties()); } } entityManager.setJpaProperties(p); entityManager.setPackagesToScan(config.getPackageToScan()); entityManager.setPersistenceProvider(new HibernatePersistenceProvider()); return entityManager; } After a lot of debugging, it looks like the entitymanager is being closed by spring. This seems to happen because EntityManagerHolder gets registered with the transaction synchronization, but I would have though this should only happen in the case of a JPA transaction but NOT when JTA is used ........... going to continue investigating at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:347) at com.sun.proxy.$Proxy44.close(Unknown Source) at org.springframework.orm.jpa.EntityManagerFactoryUtils.closeEntityManager(EntityManagerFactoryUtils.java:438) at org.springframework.orm.jpa.EntityManagerFactoryUtils$TransactionalEntityManagerSynchronization.releaseResource(EntityManagerFactoryUtils.java:511) at org.springframework.orm.jpa.EntityManagerFactoryUtils$TransactionalEntityManagerSynchronization.releaseResource(EntityManagerFactoryUtils.java:456) at org.springframework.transaction.support.ResourceHolderSynchronization.beforeCompletion(ResourceHolderSynchronization.java:77) at org.springframework.transaction.support.TransactionSynchronizationUtils.triggerBeforeCompletion(TransactionSynchronizationUtils.java:106) at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCompletion(AbstractPlatformTransactionManager.java:945) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:745) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:150)
    No Bugmate found.