From 8f877dcee2450569ef5f2320111e242d63bc3338 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 24 Jul 2017 10:42:40 +0100 Subject: [PATCH] Disable auto-config of Narayana's JMS support when JMS module absent Closes gh-9844 --- spring-boot-autoconfigure/pom.xml | 5 +++++ .../jta/NarayanaJtaConfiguration.java | 3 ++- .../jta/JtaAutoConfigurationTests.java | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/spring-boot-autoconfigure/pom.xml b/spring-boot-autoconfigure/pom.xml index a526798840..ce9e8cd2d3 100755 --- a/spring-boot-autoconfigure/pom.xml +++ b/spring-boot-autoconfigure/pom.xml @@ -597,6 +597,11 @@ jooq true + + org.jboss.narayana.jta + jms + true + org.jboss.narayana.jta jta diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/NarayanaJtaConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/NarayanaJtaConfiguration.java index 2843b6e330..da219ffc33 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/NarayanaJtaConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/NarayanaJtaConfiguration.java @@ -23,6 +23,7 @@ import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; import com.arjuna.ats.jbossatx.jta.RecoveryManagerService; +import org.jboss.narayana.jta.jms.TransactionHelper; import org.jboss.tm.XAResourceRecoveryRegistry; import org.springframework.beans.factory.ObjectProvider; @@ -150,7 +151,7 @@ public class NarayanaJtaConfiguration { } @Configuration - @ConditionalOnClass(Message.class) + @ConditionalOnClass({ Message.class, TransactionHelper.class }) static class NarayanaJtaJmsConfiguration { @Bean diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/transaction/jta/JtaAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/transaction/jta/JtaAutoConfigurationTests.java index e7548cea48..e057ce8917 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/transaction/jta/JtaAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/transaction/jta/JtaAutoConfigurationTests.java @@ -31,6 +31,7 @@ import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; import javax.transaction.xa.XAResource; +import com.arjuna.ats.jbossatx.jta.RecoveryManagerService; import com.atomikos.icatch.config.UserTransactionService; import com.atomikos.icatch.jta.UserTransactionManager; import com.atomikos.jms.AtomikosConnectionFactoryBean; @@ -52,6 +53,8 @@ import org.springframework.boot.jta.atomikos.AtomikosProperties; import org.springframework.boot.jta.bitronix.BitronixDependentBeanFactoryPostProcessor; import org.springframework.boot.jta.bitronix.PoolingConnectionFactoryBean; import org.springframework.boot.jta.bitronix.PoolingDataSourceBean; +import org.springframework.boot.jta.narayana.NarayanaBeanFactoryPostProcessor; +import org.springframework.boot.jta.narayana.NarayanaConfigurationBean; import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -137,6 +140,20 @@ public class JtaAutoConfigurationTests { this.context.getBean(JtaTransactionManager.class); } + @Test + public void narayanaSanityCheck() throws Exception { + this.context = new AnnotationConfigApplicationContext(JtaProperties.class, + NarayanaJtaConfiguration.class); + this.context.getBean(NarayanaConfigurationBean.class); + this.context.getBean(UserTransaction.class); + this.context.getBean(TransactionManager.class); + this.context.getBean(XADataSourceWrapper.class); + this.context.getBean(XAConnectionFactoryWrapper.class); + this.context.getBean(NarayanaBeanFactoryPostProcessor.class); + this.context.getBean(JtaTransactionManager.class); + this.context.getBean(RecoveryManagerService.class); + } + @Test public void defaultBitronixServerId() throws UnknownHostException { this.context = new AnnotationConfigApplicationContext(