我正在尝试配置仅在一个节点(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将石英集成到dropwizard项目中。我正在使用dropwizard 1.0.5,dropwizard-guicey 4.0.1(https://github.com/xvik/dropwizard-guicey),spinscale石英实现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格式,但是当您使用纯属性格式时,不应将值用引号引起来。
因此,在您的情况下,由于引号,它确实找不到类"org.quartz.simpl.SimpleThreadPool"
。
我建议使用主要的dropwizard配置(yaml)进行石英配置(如库文档建议),只是将所有配置都放在一个位置。