Exception for missing r:layoutResources tag

grails, grails-2.0

Solution

`<r:layoutResources/>` should appear twice in your page (or more usually in your layout GSP) - once just before `</head>` to render resources with the "head" disposition and again just before `</body>` to render the "defer" ones. It's the missing second occurrence that the error message is complaining about, the first isn't really "commented out" (it's inside an HTML comment so it will still be rendered, but its output will be commented out in the resulting HTML).

So you need to "uncomment" the first occurrence and also add the second one, or make sure that your page is using a layout that includes the `<r:layoutResources/>` tags at the right places.

Problem

I am using `grails 2.3.4` However when I start my application I get: ``` |Server running. Browse to http://localhost:8080/testApplication ....[/testApplication].[gsp] Servlet.service() for servlet [gsp] in context w ith path [/testApplication] threw exception java.lang.RuntimeException: It looks like you are missing some calls to the r:la youtResources tag. After rendering your page the following have not been rendere d: [defer] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct orAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC onstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at org.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorNewIns tance(ReflectiveInterceptor.java:986) at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstru ctor.java:77) at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteN oUnwrapNoCoerce.callConstructor(ConstructorSite.java:102) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstru ctor(CallSiteArray.java:57) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor (AbstractCallSite.java:182) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor (AbstractCallSite.java:190) at org.grails.plugin.resource.DevModeSanityFilter.doFilter(DevModeSanity Filter.groovy:54) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:210) at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doF ilterInternal(GrailsWebRequestFilter.java:69) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR equestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:210) at org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter.doFilte rInternal(HiddenHttpMethodFilter.java:67) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR equestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:210) at org.springframework.web.filter.CharacterEncodingFilter.doFilterIntern al(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR equestFilter.java:107) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(D elegatingFilterProxy.java:343) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(Delegat ingFilterProxy.java:260) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:123) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j ava:100) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav a:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp 11Processor.java:1041) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process( AbstractProtocol.java:603) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoin t.java:310) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor. java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor .java:603) at java.lang.Thread.run(Thread.java:722) ``` My `index.gsp` file looks like that: ``` <html ng-app> <head> <meta name="layout" content="main" /> <title>Title Page</title> <!-- here we are loading angularjs --> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.8/angular.min.js"></script> <!-- other way: <script src="" $ {resource(dir: 'js/lib', file: 'file.js')}"></script> --> <!-- <r:require module="angular" /> <r:layoutResources /> --> </head> <body> <div> <div> <label>Name:</label> <input type="text" ng-model="yourName" placeholder="Enter a name here"> <hr> <h1>Hello {{yourName}}!</h1> </div> </div> </body> </html> ``` As you can see the tag is commented out. So why do I get this and how to fix this long expeception? I really appreciate your answer!

Original source