grails / grails-quartz

This project provides integration of the Quartz scheduling framework into the Grails Framework
http://grails.org/plugin/quartz
Apache License 2.0
76 stars 90 forks source link

No SecurityManager in jobs (nasty exception) #85

Open kdybicz opened 7 years ago

kdybicz commented 7 years ago

Hi,

I'm getting bellow error while trying to use SecurityUtils.subject?.principal in code:

No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.ThreadContext or as a vm static singleton.  This is an invalid application configuration.
org.apache.shiro.SecurityUtils in getSecurityManager at line 123
org.apache.shiro.subject.Subject$Builder in <init> at line 627
org.apache.shiro.SecurityUtils in getSubject at line 56

(The code is common for jobs and user iterface.)

I have found possible workaround: http://grails.1312388.n4.nabble.com/Shiro-subject-on-quartz-job-td2280109.html but I would like to have something out of the box, something that will work for all of my jobs.

Does any of you know an sensible way of injectingSecurityManager orSubject in the thread context of all jobs?

Environment: Grails 2.5.4 Quartz 1.0.2 Tomcat 7 JDK 8