Ping
Ping

Reputation: 11

ClassNotFoundException when Using CronTrigger and MySQL to do scheduler

java.lang.ClassNotFoundException when Using CronTrigger and MySQL to do scheduler in Java

I am currently developing a project that require scheduler to download data from MySQL database from a server and put it into a text file stored in a fixed directory. I am using CronTrigger and scheduler to accomplish this task and my project will be reside in Tomcat version 6.0/webapps directory. However, i encountered this problem when i run my program.

Jul 5, 2013 3:10:00 PM org.quartz.impl.jdbcjobstore.JobStoreSupport triggerFired
SEVERE: Error retrieving job, setting trigger state to ERROR.
org.quartz.JobPersistenceException: Couldn't retrieve job because a required class was not found: bgoc.dwgScheduler.dwg_QuartzAutoDownloadJob [See nested exception: java.lang.ClassNotFoundException: bgoc.dwgScheduler.dwg_QuartzAutoDownloadJob]**<br>

at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveJob(JobStoreSupport.java:1328)<br>
at org.quartz.impl.jdbcjobstore.JobStoreSupport.triggerFired(JobStoreSupport.java:2789)<br>
at org.quartz.impl.jdbcjobstore.JobStoreSupport$37.execute(JobStoreSupport.java:2757)<br>
at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3662)<br>
at org.quartz.impl.jdbcjobstore.JobStoreSupport.triggerFired(JobStoreSupport.java:2751)<br>
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:313)<br>
Caused by: java.lang.ClassNotFoundException: bgoc.dwgScheduler.dwg_QuartzAutoDownloadJob <br>
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)<br>
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)<br>
at org.quartz.simpl.InitThreadContextClassLoadHelper.loadClass(InitThreadContextClassLoadHelper.java:74)<br>
at org.quartz.simpl.CascadingClassLoadHelper.loadClass(CascadingClassLoadHelper.java:118)<br>
at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.selectJobDetail(StdJDBCDelegate.java:897)<br>
at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveJob(JobStoreSupport.java:1316)<br>

I am sure that my java code is not the problem because this error does not occur all the time. However, it has a 30% occurance rate which is quite high. However, i am not sure whether my quartz file is written correctly. Below is the quartz file written.

Configure Main Scheduler Properties ##

org.quartz.scheduler.instanceName = DefaultQuartzScheduler
org.quartz.scheduler.instanceId = one

Configure ThreadPool

org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 5
org.quartz.threadPool.threadPriority = 4

Configure JobStore

org.quartz.jobStore.misfireThreshold = 5000
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.dataSource = myDS
org.quartz.jobStore.tablePrefix = QRTZ_

Configure Datasources

org.quartz.dataSource.myDS.driver = com.mysql.jdbc.Driver
org.quartz.dataSource.myDS.URL = jdbc:mysql://localhost:3307/QRTZ_BIS
org.quartz.dataSource.myDS.user = root
org.quartz.dataSource.myDS.password = password
org.quartz.dataSource.myDS.maxConnections 5

Can anyone help me with this problem? If you would like to have more information please do post, I will provide it as soon as possible.

Upvotes: 1

Views: 6083

Answers (2)

vargen_
vargen_

Reputation: 2790

I had the same situation. This was caused because I removed a previously used job, during a version release. I did not count for a few triggers (not cron, but simple delayed ones) staying in the DB. Those tried to execute but failed because their job was removed already.

What I ended up doing is putting the job back with empty execute method body (logging the fact it was called).

This way, after deploying the version with the empty method, the triggers can fire with no problem, quartz won't whine about that. In the next version you can then remove the empty job too.

Deleting manually from the quartz tables is risky and generally not advisable. You probably don't know what row(s) belong to job triggers/jobs.

Upvotes: 3

Cristian Meneses
Cristian Meneses

Reputation: 4041

Classloader complains about class bgoc.dwgScheduler.dwg_QuartzAutoDownloadJob missing.

Is this class yours? Have you checked if this class is on the classpath ?

Maybe this class is not necessary, but some other class or configuration may be importing it.

Upvotes: 1

Related Questions