Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
liuzhaozhao opened this issue Sep 3, 2021 · 1 comment · Fixed by #19904
Closed

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

liuzhaozhao opened this issue Sep 3, 2021 · 1 comment · Fixed by #19904
Assignees
Labels
kind/bug Something isn't working
Milestone

Comments

@liuzhaozhao
Copy link

liuzhaozhao commented Sep 3, 2021

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

@liuzhaozhao liuzhaozhao added the kind/bug Something isn't working label Sep 3, 2021
@quarkus-bot quarkus-bot bot added env/windows Impacts Windows machines triage/needs-triage labels Sep 3, 2021
@liuzhaozhao liuzhaozhao reopened this Sep 3, 2021
@geoand geoand self-assigned this Sep 3, 2021
@geoand geoand removed the env/windows Impacts Windows machines label Sep 3, 2021
geoand added a commit to geoand/quarkus that referenced this issue Sep 3, 2021
Before this fix, the implementations where actually
eligible for bean removal

Fixes: quarkusio#19900
@geoand
Copy link
Contributor

geoand commented Sep 3, 2021

Thanks for reporting.

#19904 should fix the issue the fix should be part of 2.2.2.Final when we release it next week.

geoand added a commit that referenced this issue Sep 3, 2021
Fix issue with skip predicates in scheduled methods
@quarkus-bot quarkus-bot bot added this to the 2.3 - main milestone Sep 3, 2021
@gsmet gsmet modified the milestones: 2.3 - main, 2.2.2.Final Sep 6, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Sep 6, 2021
Before this fix, the implementations where actually
eligible for bean removal

Fixes: quarkusio#19900
(cherry picked from commit 3614947)
gsmet pushed a commit to gsmet/quarkus that referenced this issue Sep 6, 2021
Before this fix, the implementations where actually
eligible for bean removal

Fixes: quarkusio#19900
(cherry picked from commit 3614947)
gsmet pushed a commit to gsmet/quarkus that referenced this issue Sep 6, 2021
Before this fix, the implementations where actually
eligible for bean removal

Fixes: quarkusio#19900
(cherry picked from commit 3614947)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants