And-yyy opened a new issue, #8306:
URL: https://github.com/apache/camel-quarkus/issues/8306

   ### Bug description
   
   ## Description
   
   When `quarkus.scheduler.use-composite-scheduler=true` is enabled, 
`camel-quarkus-quartz` fails to start with:
   
   ```
   UnsatisfiedResolutionException: No bean found for required type
   [interface io.quarkus.quartz.QuartzScheduler] and qualifiers [[]]
   ```
   
   The `CamelQuartzRecorder$QuartzAutowiredLifecycleStrategy` performs a 
default-qualified CDI lookup for `QuartzScheduler` at runtime 
(`Arc.container().select(QuartzScheduler.class)`). However, when composite 
scheduler mode is active, Quarkus transforms the `QuartzSchedulerImpl` bean 
metadata to add the `@Constituent` qualifier and removes the `@Default` 
qualifier. This causes the lookup to fail.
   
   See also original issue 
[quarkusio/quarkus#52629](https://github.com/quarkusio/quarkus/issues/52629)
   
   ## Minimal Reproduction
   
   **Dependencies:**
   ```xml
   <dependency>
       <groupId>io.quarkus</groupId>
       <artifactId>quarkus-quartz</artifactId>
   </dependency>
   <dependency>
       <groupId>org.apache.camel.quarkus</groupId>
       <artifactId>camel-quarkus-quartz</artifactId>
   </dependency>
   <dependency>
       <groupId>org.apache.camel.quarkus</groupId>
       <artifactId>camel-quarkus-core</artifactId>
   </dependency>
   ```
   
   **application.properties:**
   ```properties
   quarkus.scheduler.use-composite-scheduler=true
   ```
   
   No additional code needed. Simply starting the application triggers the 
error.
   
   A full minimal reproduction project is available at: 
[quartz-bug-test.zip](https://github.com/user-attachments/files/25363199/quartz-bug-test.zip)
   Execute with `./mvnw quarkus:dev`. At startup the Exception occourse.
   
   ## Root Cause
   
   In `CamelQuartzRecorder.java` (line ~93), the 
`QuartzAutowiredLifecycleStrategy` performs the following lookup:
   
   ```java
   QuartzScheduler qs = Arc.container()
       .select(QuartzScheduler.class)  // looks for @Default qualifier
       .getHandle()
       .get();
   ```
   
   When `use-composite-scheduler=true`, Quarkus' `SchedulerProcessor` 
transforms the `QuartzSchedulerImpl` bean to have the `@Constituent` qualifier 
instead of `@Default` (as confirmed by Martin Kouba from the Quarkus team in 
[quarkusio/quarkus#52629](https://github.com/quarkusio/quarkus/issues/52629)).
   
   ## Workaround
   
   Until the fix is available, this could be a viable workaround:
   
   ```java
   import io.quarkus.arc.Unremovable;
   import io.quarkus.quartz.QuartzScheduler;
   import io.quarkus.scheduler.runtime.Constituent;
   import jakarta.enterprise.context.ApplicationScoped;
   import jakarta.enterprise.inject.Produces;
   import jakarta.enterprise.inject.Typed;
   
   public class QuartzSchedulerProducer {
   
       @Produces
       @ApplicationScoped
       @Typed(QuartzScheduler.class)
       @Unremovable
       QuartzScheduler quartzScheduler(@Constituent QuartzScheduler 
constituent) {
           return constituent;
       }
   }
   ```
   
   This re-exposes the `@Constituent`-qualified `QuartzScheduler` bean with the 
`@Default` qualifier so that `CamelQuartzRecorder` can find it.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to