Grails

Application Context not avaialble in Bootstrap - Integration Tests

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.1.1
  • Fix Version/s: 1.2-M1
  • Component/s: None
  • Labels:
    None
  • Environment:
    Mac OS X
    Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 i386

Description

The following code stopped working when upgrading to 1.1.1.

import grails.util.GrailsUtil

import org.springframework.context.ApplicationContext
import org.codehaus.groovy.grails.commons.GrailsApplication
import org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes

class BootStrap {

def init = {servletContext ->
ApplicationContext applicationContext = servletContext.getAttribute(GrailsApplicationAttributes.APPLICATION_CONTEXT)
GrailsApplication application = (GrailsApplication) applicationContext.getBean("grailsApplication")

I get the a NullPointerException when invoking the getBean method on the applicationContext:

Error executing script TestApp: java.lang.NullPointerException: Cannot invoke method getBean() on null object
gant.TargetExecutionException: java.lang.NullPointerException: Cannot invoke method getBean() on null object
at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:331)
at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334)
at gant.Gant$_dispatch_closure6.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:344)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:334)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.processTargets(Gant.groovy:495)
at gant.Gant.processTargets(Gant.groovy:480)
Caused by: java.lang.NullPointerException: Cannot invoke method getBean() on null object
at BootStrap$_closure1.doCall(BootStrap.groovy:14)
at _GrailsTest_groovy$_run_closure7.doCall(_GrailsTest_groovy:261)
at _GrailsTest_groovy$_run_closure7.doCall(_GrailsTest_groovy)
at _GrailsTest_groovy$_run_closure1_closure19.doCall(_GrailsTest_groovy:110)
at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:96)
at TestApp$_run_closure1.doCall(TestApp.groovy:66)
at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324)
... 10 more

Issue Links

Activity

Hide
Sergey Nebolsin added a comment -

This issue also affects Quartz plugin: GRAILSPLUGINS-1159.

Show
Sergey Nebolsin added a comment - This issue also affects Quartz plugin: GRAILSPLUGINS-1159.
Hide
Oliver Weichhold added a comment -

Same Problem here and no the workaround isn't working Graeme.

Show
Oliver Weichhold added a comment - Same Problem here and no the workaround isn't working Graeme.
Hide
Luke Daley added a comment -
Show
Luke Daley added a comment - GRAILS-4609 caused GRAILS-6847

People

Vote (3)
Watch (6)

Dates

  • Created:
    Updated:
    Resolved: