{"action":"opened","issue":{"url":"https://api.github.com/repos/grails-plugins/grails-quartz/issues/36","labels_url":"https://api.github.com/repos/grails-plugins/grails-quartz/issues/36/labels{/name}","comments_url":"https://api.github.com/repos/grails-plugins/grails-quartz/issues/36/comments","events_url":"https://api.github.com/repos/grails-plugins/grails-quartz/issues/36/events","html_url":"https://github.com/grails-plugins/grails-quartz/issues/36","id":115698235,"number":36,"title":"java.lang.IllegalStateException: No thread-bound request found accessing grailsApplication","user":{"login":"longwa","id":361184,"avatar_url":"https://avatars.githubusercontent.com/u/361184?v=3","gravatar_id":"","url":"https://api.github.com/users/longwa","html_url":"https://github.com/longwa","followers_url":"https://api.github.com/users/longwa/followers","following_url":"https://api.github.com/users/longwa/following{/other_user}","gists_url":"https://api.github.com/users/longwa/gists{/gist_id}","starred_url":"https://api.github.com/users/longwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/longwa/subscriptions","organizations_url":"https://api.github.com/users/longwa/orgs","repos_url":"https://api.github.com/users/longwa/repos","events_url":"https://api.github.com/users/longwa/events{/privacy}","received_events_url":"https://api.github.com/users/longwa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-07T23:06:46Z","updated_at":"2015-11-07T23:06:46Z","closed_at":null,"body":"After upgrading to Grails 3 and quartz 2.0.0, we are getting this exception anytime one of our jobs tries to access grailsApplication:\r\n\r\n```\r\nCaused by: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.\r\n\tat org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:131)\r\n\tat grails.web.api.WebAttributes$Trait$Helper.currentRequestAttributes(WebAttributes.groovy:45)\r\n\tat grails.web.api.WebAttributes$Trait$Helper$currentRequestAttributes.call(Unknown Source)\r\n\tat com.triu.system.MailRetryJob.currentRequestAttributes(MailRetryJob.groovy)\r\n\tat grails.web.api.WebAttributes$Trait$Helper.getGrailsAttributes(WebAttributes.groovy:54)\r\n\tat grails.web.api.WebAttributes$Trait$Helper$getGrailsAttributes$2.call(Unknown Source)\r\n\tat com.triu.system.MailRetryJob.getGrailsAttributes(MyJob.groovy)\r\n\tat grails.web.api.WebAttributes$Trait$Helper.getGrailsApplication(WebAttributes.groovy:134)\r\n\tat grails.web.api.WebAttributes$Trait$Helper$getGrailsApplication$6.call(Unknown Source)\r\n\tat com.triu.system.MailRetryJob.getGrailsApplication(MailRetryJob.groovy)\r\n\tat com.triu.system.process.ManagedProcess.getProperty(ManagedProcess.groovy)\r\n\tat com.triu.system.MailRetryJob.executeJob(MailRetryJob.groovy:69)\r\n\tat com.triu.system.process.ManagedJob$_execute_closure1.doCall(ManagedJob.groovy:73)\r\n```\r\nIt looks like the problem is that QuartzJob implements the new WebAttributes trait but apparently it assumes that properties will be available via `RequestContextHolder`. I'm not really sure why a quartz job would ever satisfy this constraint since it runs in a separate thread.\r\n\r\nWe actually inject `grailsApplication` into our Jobs that need them but the trait is causing that injection to be ignored in favor of the WebAttributes getter."}}