Search code examples
javajava-8quartz-schedulerguicedropwizard

Quartz ClassNotFoundException for SimpleThreadPool


I'm trying to configure a quartz scheduler that will only run on one node (https://github.com/spinscale/dropwizard-jobs#using-dropwizard-jobs-in-a-clustered-environment). Whenever I setup the quartz threadpool, it tells me that SimpleThreadPool cannot be found, even though it's loaded in my project via spinscale/dropwizard-jobs. The version loaded in is quartz-2.2.3

I'm using 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 implementation 3.0.0.

I've hooked up dependency injection via this example here: https://github.com/xvik/dropwizard-guicey-examples/tree/master/dropwizard-jobs

And I've added the following file to my project 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"

This is the exception I'm seeing

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)

Solution

  • Example in documentation use yaml format, but, as you using pure properties format, you shouldn't wrap values in quotes.

    So in your case, it indeed can't find class "org.quartz.simpl.SimpleThreadPool" because of the quotes.

    I would suggest to use main dropwizard config (yaml) for quartz configuration (as library doc suggest) just to keep all configs in one place.