History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GRAILSPLUGINS-190
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Sergey Nebolsin
Reporter: Jim Shingler
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Grails Plugins

Grails Job doesn't reload on a change

Created: 07/Dec/07 08:46 PM   Updated: 16/May/08 06:04 AM
Component/s: Grails-Quartz
Affects Version/s: Grails-Quartz 0.2
Fix Version/s: Grails-Quartz 0.3

Time Tracking:
Not Specified

File Attachments: 1. Text File grails-quartz-reloadservices-GRAILSPLUGINS-190.patch (2 kb)

Environment: Window, Java 1.5, Grails 1.0 RC2, Grails Quarz 0.2


 Description  « Hide
It appears as though grails jobs are not reloaded when the job is changed.

created a job with a simple println,

started the app (grails run-app)

saw the output,

changed the println and saved.

the output did not change.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Wolfgang Schell - 29/Jan/08 04:55 PM
This is caused by the quartz scheduler being shut down.

When the job class is reloaded, the bean factory, which created the scheduler is destroyed. This leads to the scheduler being shut down, which in turn prohibits (re-)scheduling jobs.

This happens in QuartzGrailsPlugin.groovy:123:

def onChange = { event ->
...
event.ctx.registerBeanDefinition("${fullName}", beans.getBeanDefinition("${fullName}"))
...
}


Wolfgang Schell - 31/Jan/08 05:13 AM
After some debugging, I found out, that the problem ist not the BeanFactory being destroyed, but rather the scheduler being destroyed because it is registered as a dependency to the <MyJobClass>Trigger class (see methods registerDependentBean() and destroySingleton() of org.springframework.beans.factory.support.DefaultSingletonBeanRegistry).

The solution is to avoid these dependencies by delaying the registration of the job triggers. The attached patch registers the job triggers in doWithApplicationContext() instead of doWithSpring().

Changed and newly created jobs are now created/updated correctly without the scheduler being shut down.

One issue remains: If an existing job is deleted (e.g: rm grails-app/jobs/MyJob.groovy), the job will still be running.
I Haven't investigated this issue properly, but I think this is rather a problem of the resource watcher. Maybe deleted resource events are not propagated to onChange()?


Sergey Nebolsin - 20/Feb/08 12:06 PM
Patch applied, thank you.