How to solve quartz thread count must be > 0 exception?

1. The problem

Sometimes, we encounter this Exception when using quartz to schedule jobs.

org.quartz.SchedulerConfigException: Thread count must be > 0
at org.quartz.simpl.SimpleThreadPool.initialize( ~[quartz-2.2.1.jar:na]
at org.quartz.impl.StdSchedulerFactory.instantiate( ~[quartz-2.2.1.jar:na]
at org.quartz.impl.StdSchedulerFactory.getScheduler( ~[quartz-2.2.1.jar:na]
at org.quartz.impl.StdSchedulerFactory.getDefaultScheduler( ~[quartz-2.2.1.jar:na]
at JobService.startJobs( [job-3.0.0-20180731-RELEASE.jar:na]
at JobService.reloadJobsByIntervalReally( [job-3.0.0-20180731-RELEASE.jar:na]
at JobService.lambda$reloadJobsByInterval$13( [job-x-RELEASE.jar:na]
at ~[na:1.8.0_131]

2. Environments

  • JDK 1.8
  • Quartz 2.2.1
  • Springboot 1.5.9.RELEASE

3. The solution

  • According to post

    I searched the in the classpath, and I did find a, and delete it. But the issue still exist after restart.

  • Clear the classpath I found many backup jars in the root of the deploy dir, I delete the backup jars like this:

rm -rf myjob.jar.bak*
rm -rf myjob.exec.jar.bak*

At last, there is only one myjob.jar in the classpath, and the jar does not contain any in it. Restart the app, the problem disappeared.

3. Conclusion

To summarize: - There is no need for the file for most projects, If you find one, just delete it. - If you need the file, you can specify the content of the thread count properites like this:

org.quartz.scheduler.instanceName = MyScheduler
org.quartz.threadPool.threadCount = 3
org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
org.quartz.plugin.jobInitializer.class =org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin 
org.quartz.plugin.jobInitializer.fileNames = quartz-config.xml 
org.quartz.plugin.jobInitializer.failOnFileNotFound = true

If you don’t find any file in the classpath, check your jars, and make sure there are not any backup jars in the classpath