diff --git a/extensions/narayana-jta/deployment/src/main/java/io/quarkus/narayana/jta/deployment/NarayanaJtaProcessor.java b/extensions/narayana-jta/deployment/src/main/java/io/quarkus/narayana/jta/deployment/NarayanaJtaProcessor.java index c661f5ea866b6..214fa3bf3ec0b 100644 --- a/extensions/narayana-jta/deployment/src/main/java/io/quarkus/narayana/jta/deployment/NarayanaJtaProcessor.java +++ b/extensions/narayana-jta/deployment/src/main/java/io/quarkus/narayana/jta/deployment/NarayanaJtaProcessor.java @@ -204,6 +204,11 @@ public void startRecoveryService(NarayanaJtaRecorder recorder, @BuildStep(onlyIf = IsTest.class) void testTx(BuildProducer generatedBeanBuildItemBuildProducer, BuildProducer additionalBeans) { + + if (!testTransactionOnClassPath()) { + return; + } + //generate the annotated interceptor with gizmo //all the logic is in the parent, but we don't have access to the //binding annotation here @@ -219,6 +224,15 @@ void testTx(BuildProducer generatedBeanBuildItemBuildPro .addBeanClass(TEST_TRANSACTION).build()); } + private static boolean testTransactionOnClassPath() { + try { + Class.forName(TEST_TRANSACTION, false, Thread.currentThread().getContextClassLoader()); + return true; + } catch (ClassNotFoundException ignored) { + return false; + } + } + @BuildStep public ContextConfiguratorBuildItem transactionContext(ContextRegistrationPhaseBuildItem contextRegistrationPhase) { return new ContextConfiguratorBuildItem(contextRegistrationPhase.getContext() diff --git a/extensions/panache/hibernate-reactive-panache-common/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/common/deployment/PanacheJpaCommonResourceProcessor.java b/extensions/panache/hibernate-reactive-panache-common/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/common/deployment/PanacheJpaCommonResourceProcessor.java index 307a82c770060..8190c8dfa5989 100644 --- a/extensions/panache/hibernate-reactive-panache-common/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/common/deployment/PanacheJpaCommonResourceProcessor.java +++ b/extensions/panache/hibernate-reactive-panache-common/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/common/deployment/PanacheJpaCommonResourceProcessor.java @@ -61,6 +61,11 @@ public final class PanacheJpaCommonResourceProcessor { @BuildStep(onlyIf = IsTest.class) void testTx(BuildProducer generatedBeanBuildItemBuildProducer, BuildProducer additionalBeans) { + + if (!testReactiveTransactionOnClassPath()) { + return; + } + //generate the annotated interceptor with gizmo //all the logic is in the parent, but we don't have access to the //binding annotation here @@ -76,6 +81,15 @@ void testTx(BuildProducer generatedBeanBuildItemBuildPro .addBeanClass(TEST_REACTIVE_TRANSACTION).build()); } + private static boolean testReactiveTransactionOnClassPath() { + try { + Class.forName(TEST_REACTIVE_TRANSACTION, false, Thread.currentThread().getContextClassLoader()); + return true; + } catch (ClassNotFoundException ignored) { + return false; + } + } + @BuildStep void registerInterceptors(BuildProducer additionalBeans) { AdditionalBeanBuildItem.Builder builder = AdditionalBeanBuildItem.builder();