SimpleThreadPool 的 Quartz ClassNotFoundException

Quartz ClassNotFoundException for SimpleThreadPool

我正在尝试配置一个仅在一个节点 (https://github.com/spinscale/dropwizard-jobs#using-dropwizard-jobs-in-a-clustered-environment) 上 运行 的石英调度程序。每当我设置石英线程池时,它都会告诉我找不到 SimpleThreadPool,即使它是通过 spinscale/dropwizard-jobs 加载到我的项目中的。加载的版本是quartz-2.2.3

我正在使用 https://github.com/spinscale/dropwizard-jobs to integrate quartz into a dropwizard project. I'm using dropwizard 1.0.5, dropwizard-guicey 4.0.1 (https://github.com/xvik/dropwizard-guicey), spinscale quartz 实现 3.0.0.

我在这里通过这个例子连接了依赖注入:https://github.com/xvik/dropwizard-guicey-examples/tree/master/dropwizard-jobs

并且我已将以下文件添加到我的项目中 quartz.properties

org.quartz.scheduler.instanceName: "scheduler"
org.quartz.scheduler.instanceId: "AUTO"
org.quartz.scheduler.skipUpdateCheck: "true"
org.quartz.threadPool.class: "org.quartz.simpl.SimpleThreadPool"
org.quartz.threadPool.threadCount: "10"
org.quartz.threadPool.threadPriority: "5"
org.quartz.jobStore.misfireThreshold: "60000"
org.quartz.jobStore.class: "org.quartz.impl.jdbcjobstore.JobStoreTX"
org.quartz.jobStore.driverDelegateClass: "org.quartz.impl.jdbcjobstore.StdJDBCDelegate"
org.quartz.jobStore.useProperties: "false"
org.quartz.jobStore.dataSource: "myDS"
org.quartz.jobStore.tablePrefix: "QRTZ_"
org.quartz.jobStore.isClustered: "true"
org.quartz.dataSource.myDS.driver: "org.postgresql.Driver"
org.quartz.dataSource.myDS.URL: "jdbc:mysql://localhost:3306/quartz"
org.quartz.dataSource.myDS.user: user
org.quartz.dataSource.myDS.password: pass
org.quartz.dataSource.myDS.maxConnections: "5"
org.quartz.dataSource.myDS.validationQuery: "select 1"

这是我看到的例外情况

ERROR [2018-03-12 04:38:29,755] io.dropwizard.cli.ServerCommand: Unable to start server, shutting down
! java.lang.ClassNotFoundException: "org.quartz.simpl.SimpleThreadPool"
! at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
! at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
! at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
! at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
! at org.quartz.simpl.InitThreadContextClassLoadHelper.loadClass(InitThreadContextClassLoadHelper.java:72)
! at org.quartz.simpl.CascadingClassLoadHelper.loadClass(CascadingClassLoadHelper.java:114)
! at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:822)
! ... 17 common frames omitted
! Causing: org.quartz.SchedulerException: ThreadPool class '"org.quartz.simpl.SimpleThreadPool"' could not be instantiated.
! at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:824)
! at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1525)
! at org.quartz.impl.StdSchedulerFactory.getDefaultScheduler(StdSchedulerFactory.java:1541)
! at de.spinscale.dropwizard.jobs.JobManager.start(JobManager.java:50)
! at io.dropwizard.lifecycle.JettyManaged.doStart(JettyManaged.java:27)
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
! at org.eclipse.jetty.server.Server.start(Server.java:411)
! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
! at org.eclipse.jetty.server.Server.doStart(Server.java:378)
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
! at io.dropwizard.cli.ServerCommand.run(ServerCommand.java:53)
! at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:44)
! at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:85)
! at io.dropwizard.cli.Cli.run(Cli.java:75)
! at io.dropwizard.Application.run(Application.java:79)

Example in documentation 使用 yaml 格式,但是,当您使用纯属性格式时,您不应将值用引号引起来。

所以在你的情况下,它确实找不到 class "org.quartz.simpl.SimpleThreadPool" 因为引号。

我建议使用主要的 dropwizard 配置 (yaml) 进行石英配置(如库文档建议的那样)只是为了将所有配置保存在一个地方。