Project

General

Profile

Actions

Task #612

closed

Task scheduler -> scheduled tasks: missing class

Added by Filip Měšťánek over 6 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Low
Assignee:
Radek Tomiška
Category:
Scheduler
Target version:
Start date:
07/31/2017
Due date:
% Done:

100%

Estimated time:
2.00 h
Owner:

Description

When testing, I created a class for scheduler and scheduled a task. Then I deleted the class and went to the task scheduler -> scheduled tasks tab. The server threw 500 and no tasks were on the agenda (sorry, don't have the stack trace).

I think IdM should be prepared for this situation. and show meaning full results (For example show the scheduled task with a red background). This situation can happen for example when migrating to a new version.

Actions #1

Updated by Radek Tomiška over 6 years ago

  • Target version set to Diamond (7.4.0)
  • Estimated time set to 2.00 h

I agree, i've added this check to authorization evaluators, i'll add it here too.

Actions #2

Updated by Radek Tomiška over 6 years ago

  • Status changed from New to Needs feedback
  • Assignee changed from Radek Tomiška to Filip Měšťánek
  • % Done changed from 0 to 90

ClassNotFoundException is thrown in read job detail method => i don't have task detail to show him in table in some disabled mode, so I added check and removed task type is automatically removed from scheduler, if ClassNotFoundException occurs.

commit:
https://github.com/bcvsolutions/CzechIdMng/commit/8c4b59d294d21b42e1c972a5756c12649d4ba1b1

Could you pls do a feedback?

Actions #3

Updated by Filip Měšťánek over 6 years ago

  • Assignee changed from Filip Měšťánek to Radek Tomiška

I created a custom class TestTask. I scheduled it (to start every 5 sec), stopped the server, removed the task and started the server again. The server failed to load with the following exception. The problem may be, that the task was already waiting in the queue (I have no automatic task execution).

org.springframework.context.ApplicationContextException: Failed to start bean 'schedulerFactoryBean'; nested exception is org.springframework.scheduling.SchedulingException: Could not start Quartz Scheduler; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.JobPersistenceException: Couldn't store trigger '4f8f136e7682-e0a7eaac-a0bb-42a0-88bd-038796e40ba5.fb289e15777a-481425a3-87e2-483d-b57c-9916ba33bfe2' for 'default.4f8f136e7682-e0a7eaac-a0bb-42a0-88bd-038796e40ba5' job:Couldn't retrieve job because a required class was not found: eu.bcvsolutions.idm.core.scheduler.service.TestTask [See nested exception: org.quartz.JobPersistenceException: Couldn't retrieve job because a required class was not found: eu.bcvsolutions.idm.core.scheduler.service.TestTask [See nested exception: java.lang.ClassNotFoundException: eu.bcvsolutions.idm.core.scheduler.service.TestTask]]]
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:176)
    at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:51)
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:346)
    at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:149)
    at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:112)
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:852)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:140)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:760)
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:360)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
    at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:150)
    at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:130)
    at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:85)
    at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5166)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.scheduling.SchedulingException: Could not start Quartz Scheduler; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.JobPersistenceException: Couldn't store trigger '4f8f136e7682-e0a7eaac-a0bb-42a0-88bd-038796e40ba5.fb289e15777a-481425a3-87e2-483d-b57c-9916ba33bfe2' for 'default.4f8f136e7682-e0a7eaac-a0bb-42a0-88bd-038796e40ba5' job:Couldn't retrieve job because a required class was not found: eu.bcvsolutions.idm.core.scheduler.service.TestTask [See nested exception: org.quartz.JobPersistenceException: Couldn't retrieve job because a required class was not found: eu.bcvsolutions.idm.core.scheduler.service.TestTask [See nested exception: java.lang.ClassNotFoundException: eu.bcvsolutions.idm.core.scheduler.service.TestTask]]]
    at org.springframework.scheduling.quartz.SchedulerFactoryBean.start(SchedulerFactoryBean.java:718)
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:173)
    ... 23 common frames omitted
Caused by: org.quartz.SchedulerConfigException: Failure occured during job recovery.
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.schedulerStarted(JobStoreSupport.java:692)
    at org.quartz.core.QuartzScheduler.start(QuartzScheduler.java:567)
    at org.quartz.impl.StdScheduler.start(StdScheduler.java:142)
    at org.springframework.scheduling.quartz.SchedulerFactoryBean.startScheduler(SchedulerFactoryBean.java:648)
    at org.springframework.scheduling.quartz.SchedulerFactoryBean.start(SchedulerFactoryBean.java:715)
    ... 24 common frames omitted
Caused by: org.quartz.JobPersistenceException: Couldn't store trigger '4f8f136e7682-e0a7eaac-a0bb-42a0-88bd-038796e40ba5.fb289e15777a-481425a3-87e2-483d-b57c-9916ba33bfe2' for 'default.4f8f136e7682-e0a7eaac-a0bb-42a0-88bd-038796e40ba5' job:Couldn't retrieve job because a required class was not found: eu.bcvsolutions.idm.core.scheduler.service.TestTask
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.storeTrigger(JobStoreSupport.java:1223)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.doUpdateOfMisfiredTrigger(JobStoreSupport.java:1037)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.recoverMisfiredJobs(JobStoreSupport.java:986)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.recoverJobs(JobStoreSupport.java:866)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$1.executeVoid(JobStoreSupport.java:838)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$VoidTransactionCallback.execute(JobStoreSupport.java:3719)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$VoidTransactionCallback.execute(JobStoreSupport.java:3717)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3803)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.recoverJobs(JobStoreSupport.java:834)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.schedulerStarted(JobStoreSupport.java:690)
    ... 28 common frames omitted
Caused by: org.quartz.JobPersistenceException: Couldn't retrieve job because a required class was not found: eu.bcvsolutions.idm.core.scheduler.service.TestTask
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveJob(JobStoreSupport.java:1388)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.storeTrigger(JobStoreSupport.java:1205)
    ... 37 common frames omitted
Caused by: java.lang.ClassNotFoundException: eu.bcvsolutions.idm.core.scheduler.service.TestTask
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1274)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1108)
    at org.springframework.scheduling.quartz.ResourceLoaderClassLoadHelper.loadClass(ResourceLoaderClassLoadHelper.java:76)
    at org.springframework.scheduling.quartz.ResourceLoaderClassLoadHelper.loadClass(ResourceLoaderClassLoadHelper.java:81)
    at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.selectJobDetail(StdJDBCDelegate.java:852)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveJob(JobStoreSupport.java:1385)
    ... 38 common frames omitted

Then I tried again, but this time I scheduled the task to run in future (one time start) and the queue was empty. This exception was thrown during the startup as WARNing, the server successfully loaded, and the task is not visible in the scheduled tasks category.

org.quartz.JobPersistenceException: Couldn't retrieve job because a required class was not found: eu.bcvsolutions.idm.core.scheduler.service.TestTask
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveJob(JobStoreSupport.java:1388)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$9.execute(JobStoreSupport.java:1377)
    at org.quartz.impl.jdbcjobstore.JobStoreCMT.executeInLock(JobStoreCMT.java:245)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeWithoutLock(JobStoreSupport.java:3739)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveJob(JobStoreSupport.java:1374)
    at org.quartz.core.QuartzScheduler.getJobDetail(QuartzScheduler.java:1518)
    at org.quartz.impl.StdScheduler.getJobDetail(StdScheduler.java:498)
    at eu.bcvsolutions.idm.core.scheduler.service.impl.DefaultSchedulerManager.getTask(DefaultSchedulerManager.java:130)
    at eu.bcvsolutions.idm.core.scheduler.service.impl.DefaultSchedulerManager.getAllTasks(DefaultSchedulerManager.java:104)
    at eu.bcvsolutions.idm.core.scheduler.config.AbstractScheduledTaskInitializer.initScheduledTask(AbstractScheduledTaskInitializer.java:108)
    at eu.bcvsolutions.idm.core.scheduler.config.AbstractScheduledTaskInitializer.onApplicationEvent(AbstractScheduledTaskInitializer.java:60)
    at eu.bcvsolutions.idm.core.scheduler.config.AbstractScheduledTaskInitializer.onApplicationEvent(AbstractScheduledTaskInitializer.java:1)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:381)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:335)
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:855)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:140)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:760)
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:360)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
    at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:150)
    at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:130)
    at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:85)
    at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5166)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: eu.bcvsolutions.idm.core.scheduler.service.TestTask
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1274)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1108)
    at org.springframework.scheduling.quartz.ResourceLoaderClassLoadHelper.loadClass(ResourceLoaderClassLoadHelper.java:76)
    at org.springframework.scheduling.quartz.ResourceLoaderClassLoadHelper.loadClass(ResourceLoaderClassLoadHelper.java:81)
    at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.selectJobDetail(StdJDBCDelegate.java:852)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveJob(JobStoreSupport.java:1385)
    ... 34 common frames omitted

So the problem persists, if the task is waiting in the queue - but I am not sure if that is that much important? Or even if it can be easily solved as it is some quartz/spring internal thing.

Actions #4

Updated by Radek Tomiška over 6 years ago

Thx for feedback! I'll try to add another check, when trigger is executed.

Actions #5

Updated by Radek Tomiška over 6 years ago

  • Assignee changed from Radek Tomiška to Filip Měšťánek

I've added task type check before scheduler starts.

Commit:
https://github.com/bcvsolutions/CzechIdMng/commit/aec9b31482825606c8d9ba0f66a441685a135c74#diff-bdae72c3c696ffb5e109f96b4e25b47e

Could you pls do a feedback once again?

Actions #6

Updated by Filip Měšťánek over 6 years ago

  • Assignee changed from Filip Měšťánek to Radek Tomiška

It works now. When there was a scheduled task waiting in the queue and I removed the class, the task in the queue turned to failed with the code LONG_RUNNING_TASK_NOT_FOUND (which I think is good - the administrator can see that something happened). The task disappeared from the scheduled tasks category - here it would be better if it also was shown with a failed status, but we discussed that before.

Good job

Actions #7

Updated by Radek Tomiška over 6 years ago

  • Status changed from Needs feedback to Closed
  • % Done changed from 90 to 100

Thx!

Actions

Also available in: Atom PDF