snowdrop-zen / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
1 stars 0 forks source link

There must be exactly one bean that matches the skip predicate #411

Closed snowdrop-bot closed 3 years ago

snowdrop-bot commented 3 years ago

Describe the bug

@Slf4j
@ApplicationScoped
public class TestJob {
    @Scheduled(every="10s", skipExecutionIf = TestPredicate.class)
    void test() {
        log.info("Scheduled job execute");
    }
}
@Singleton
public class TestPredicate implements Scheduled.SkipPredicate {
    @Override
    public boolean test(ScheduledExecution execution) {
        return false;
    }
}

I am going to test the skip function of quarkus-scheduler, when I start Quarkus, the following error is printed

2021-09-03 19:08:53.617[ERROR]-[main]-[i.q.d.d.IsolatedDevModeMain(-1)]: Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
    [error]: Build step io.quarkus.arc.deployment.ArcProcessor#generateResources threw an exception: javax.enterprise.inject.spi.DeploymentException: java.lang.IllegalStateException: There must be exactly one bean that matches the skip predicate: "cn.ecpark.service.sample.quarkus.TestPredicate" on: @Scheduled(every = "10s",skipExecutionIf = cn.ecpark.service.sample.quarkus.TestPredicate)
    at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:1094)
    at io.quarkus.arc.processor.BeanProcessor.processValidationErrors(BeanProcessor.java:142)
    at io.quarkus.arc.deployment.ArcProcessor.generateResources(ArcProcessor.java:447)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
    at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
    at java.base/java.lang.Thread.run(Thread.java:834)
    at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.lang.IllegalStateException: There must be exactly one bean that matches the skip predicate: "cn.ecpark.service.sample.quarkus.TestPredicate" on: @Scheduled(every = "10s",skipExecutionIf = cn.ecpark.service.sample.quarkus.TestPredicate)
    at io.quarkus.scheduler.deployment.SchedulerProcessor.validateScheduled(SchedulerProcessor.java:412)
    at io.quarkus.scheduler.deployment.SchedulerProcessor.validateScheduledBusinessMethods(SchedulerProcessor.java:189)
    ... 11 more

Expected behavior

The log prints "Scheduled job execute" every 10 seconds

Actual behavior

exception log

How to Reproduce?

No response

Output of uname -a or ver

Microsoft Windows [Version 10.0.22000.168]

Output of java -version

java version "11.0.10" 2021-01-19

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.1.4.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.1

Additional information

No response


https://github.com/quarkusio/quarkus/issues/19900


$upstream:19900$