You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The GroovyPageLayoutFinder is not yet fully initialized during the BootStrap sequence. The field viewResolver is still null during BootStrap, which results in the exception below.
I did some debugging and it seems that both GroovyPageLayoutFinder and GrailsApplicationPostProcessor are Spring listeners that handle the ContextRefreshedEvent. Since both have no order specified, the default order is applied and it seems that GrailsApplicationPostProcessor comes before GroovyPageLayoutFinder. This results in the problem of this issue, as the viewResolver is set in the event handler onApplicationEvent.
Example that reproduces the problem uploaded to Github
Full description of the issue provided (see below)
Steps to Reproduce
create new grails 4.1.0.M1 application
use BootStrap class and GSP file from the description above
run application
Expected Behaviour
Tell us what should happen
Actual Behaviour
org.grails.taglib.GrailsTagException: [views/email/test.gsp:11] Error executing tag <g:applyLayout>: Unable to resolve view
at org.grails.gsp.GroovyPage.throwRootCause(GroovyPage.java:473)
at org.grails.gsp.GroovyPage.invokeTag(GroovyPage.java:415)
at org.grails.gsp.GroovyPage$invokeTag$4.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171)
at C__Users_david_IdeaProjects_grails_410_grails_app_views_email_test_gsp.run(C__Users_david_IdeaProjects_grails_410_grails_app_views_email_test_gsp:31)
at org.grails.gsp.GroovyPageWritable.doWriteTo(GroovyPageWritable.java:162)
at org.grails.gsp.GroovyPageWritable.writeTo(GroovyPageWritable.java:82)
at groovy.lang.Writable$writeTo.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
at grails.gsp.PageRenderer.renderViewToWriter(PageRenderer.groovy:122)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:193)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:61)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:194)
at grails.gsp.PageRenderer.render(PageRenderer.groovy:66)
at grails.gsp.PageRenderer$render.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
at grails_410.BootStrap$_closure1.doCall(BootStrap.groovy:8)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1029)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1143)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1029)
at groovy.lang.Closure.call(Closure.java:412)
at groovy.lang.Closure.call(Closure.java:406)
at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:594)
at grails.util.Environment.executeForEnvironment(Environment.java:587)
at grails.util.Environment.executeForCurrentEnvironment(Environment.java:563)
at org.grails.web.servlet.boostrap.DefaultGrailsBootstrapClass.callInit(DefaultGrailsBootstrapClass.java:74)
at org.grails.web.servlet.context.GrailsConfigUtils.executeGrailsBootstraps(GrailsConfigUtils.java:83)
at org.grails.plugins.web.servlet.context.BootStrapClassRunner.onStartup(BootStrapClassRunner.groovy:56)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy:269)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:897)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at grails.boot.GrailsApp.run(GrailsApp.groovy:96)
at grails.boot.GrailsApp.run(GrailsApp.groovy:456)
at grails.boot.GrailsApp.run(GrailsApp.groovy:443)
at grails_410.Application.main(Application.groovy:11)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.RuntimeException: Unable to resolve view
at org.grails.web.sitemesh.GroovyPageLayoutFinder.getNamedDecorator(GroovyPageLayoutFinder.java:201)
at org.grails.web.sitemesh.GroovyPageLayoutFinder.getNamedDecorator(GroovyPageLayoutFinder.java:176)
at org.grails.web.sitemesh.GrailsLayoutDecoratorMapper.getNamedDecorator(GrailsLayoutDecoratorMapper.java:79)
at com.opensymphony.module.sitemesh.mapper.AbstractDecoratorMapper.getNamedDecorator(AbstractDecoratorMapper.java:50)
at org.grails.plugins.web.taglib.RenderTagLib.findDecorator(RenderTagLib.groovy:195)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1262)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1029)
at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:1027)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:1010)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethodSafe(InvokerHelper.java:99)
at org.grails.plugins.web.taglib.RenderTagLib$_closure1.doCall(RenderTagLib.groovy:157)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1029)
at groovy.lang.Closure.call(Closure.java:412)
at org.grails.gsp.GroovyPage.invokeTagLibClosure(GroovyPage.java:446)
at org.grails.gsp.GroovyPage.invokeTag(GroovyPage.java:364)
... 68 common frames omitted
Caused by: java.lang.NullPointerException: null
at org.grails.web.sitemesh.GroovyPageLayoutFinder.getNamedDecorator(GroovyPageLayoutFinder.java:193)
... 95 common frames omitted
Environment Information
Operating System: Windows 10
Grails Version: 4.1.0.M1
JDK Version: JDK 11
The text was updated successfully, but these errors were encountered:
davidkron
changed the title
Grails 4.1.0.M1: GroovyPageLayoutFinder is not properly inititialized during BootStrap
Grails 5.0.0.M2: GroovyPageLayoutFinder is not properly inititialized during BootStrap
Jul 21, 2021
The
GroovyPageLayoutFinder
is not yet fully initialized during the BootStrap sequence. The fieldviewResolver
is still null during BootStrap, which results in the exception below.I did some debugging and it seems that both
GroovyPageLayoutFinder
andGrailsApplicationPostProcessor
are Spring listeners that handle theContextRefreshedEvent
. Since both have no order specified, the default order is applied and it seems thatGrailsApplicationPostProcessor
comes beforeGroovyPageLayoutFinder
. This results in the problem of this issue, as theviewResolver
is set in the event handleronApplicationEvent
.BootStrap.groovy:
/grails-app/views/email/test.gsp:
Task List
Steps to Reproduce
Expected Behaviour
Tell us what should happen
Actual Behaviour
Environment Information
The text was updated successfully, but these errors were encountered: