codeconsole opened a new pull request, #15195:
URL: https://github.com/apache/grails-core/pull/15195
# The Problem
```
Caused by: java.lang.IllegalStateException:
org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@48300ca8
has not been refreshed yet
at
org.springframework.context.support.AbstractApplicationContext.assertBeanFactoryActive(AbstractApplicationContext.java:1262)
at
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1280)
at
org.grails.web.context.ServletEnvironmentGrailsApplicationDiscoveryStrategy.findGrailsApplication(ServletEnvironmentGrailsApplicationDiscoveryStrategy.groovy:54)
at grails.util.Holders.findApplication(Holders.java:126)
at
org.grails.plugins.web.controllers.api.ControllersDomainBindingApi.autowire(ControllersDomainBindingApi.java:90)
at
org.grails.plugins.web.controllers.api.ControllersDomainBindingApi.initialize(ControllersDomainBindingApi.java:50)
at
com.pixoto.community.CategoryParticipant.<init>(CategoryParticipant.groovy)
at
java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
... 43 common frames omitted
```
This is only an issue during a Spring Dev Tools restart, but this fixes the
issue.
``` groovy
this.resource = resource.getDeclaredConstructor().newInstance() as
GormAllOperations<T>
```
results in a domain object instantiation during the constructor, which:
1. Triggers Grails GORM enhancements
2. Calls ControllersDomainBindingApi.initialize()
3. Tries to access Holders.findApplication()
4. Fails during DevTools restart when ApplicationContext is being switched
# The Fix
Lazy initialize the resource
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]