title: Using abstract Services in Grails
body: <p>I am adding features to a Grails 2.2.3 application, and I have the following two Services:</p>
  
  <pre><code>abstract class AbstractProcessService {
      def grailsApplication
  
      ConfigObject getConfig() {
          return grailsApplication.config.processes
      }
  }
  
  class PhotoMoverService extends AbstractProcessService {
      void processPhotos() {
          // Method body
      }
  
      private ConfigObject getPhotoConfig() {
          config.photoMover
      }
  }
  </code></pre>
  
  <p>When a Quartz job finally goes to run the <code>processPhotos()</code> method of <code>PhotoMoverService</code>, the following error occurs:</p>
  
  <pre><code>core.ErrorLogger An error occured instantiating job to be executed. job= 'Photo Processes.com.company.processes.PhotoMoverJob'
  org.quartz.SchedulerException: Job instantiation failed [See nested exception: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.company.processes.PhotoMoverJob': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'photoMoverService': Cannot create inner bean '(inner bean)' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#2': Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public java.lang.Object org.codehaus.groovy.grails.commons.AbstractGrailsClass.newInstance()] threw exception; nested exception is org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [com.company.processes.PhotoMoverService]!]
      at org.quartz.core.JobRunShell.initialize(JobRunShell.java:127)
      at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:375)
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.company.processes.PhotoMoverJob': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'photoMoverService': Cannot create inner bean '(inner bean)' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#2': Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public java.lang.Object org.codehaus.groovy.grails.commons.AbstractGrailsClass.newInstance()] threw exception; nested exception is org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [com.company.processes.PhotoMoverService]!
      at grails.plugins.quartz.GrailsJobFactory.createJobInstance(GrailsJobFactory.java:48)
      at grails.plugins.quartz.QuartzMonitorJobFactory.createJobInstance(QuartzMonitorJobFactory.groovy:22)
      ... 2 more
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'photoMoverService': Cannot create inner bean '(inner bean)' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#2': Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public java.lang.Object org.codehaus.groovy.grails.commons.AbstractGrailsClass.newInstance()] threw exception; nested exception is org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [com.company.processes.PhotoMoverService]!
      ... 4 more
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#2': Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public java.lang.Object org.codehaus.groovy.grails.commons.AbstractGrailsClass.newInstance()] threw exception; nested exception is org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [com.company.processes.PhotoMoverService]!
      ... 4 more
  Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public java.lang.Object org.codehaus.groovy.grails.commons.AbstractGrailsClass.newInstance()] threw exception; nested exception is org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [com.company.processes.PhotoMoverService]!
      ... 4 more
  Caused by: org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [com.company.processes.PhotoMoverService]!
      ... 4 more
  Caused by: java.lang.NullPointerException: Cannot get property 'config' on null object
      at com.company.processes.AbstractProcessService.getConfig(AbstractProcessService.groovy:23)
      at com.company.processes.PhotoMoverService.getPhotoConfig(PhotoMoverService.groovy:213)
      ... 4 more
  </code></pre>
  
  <p>When I debug the application, <code>grailsApplication</code> in <code>AbstractProcessService</code> is null like it is not being injected properly. Can anyone tell me <strong>1)</strong> Why it is not being injected and <strong>2)</strong> what I can do to make that happen. Thanks!</p>