当我运行集成测试并尝试渲染模板时,我收到以下错误。这个独特的部分是模板在第93行渲染模板。我这样做的原因是有一个我正在渲染的模板将其转换为PDF,它包含一个调用视图模板的样式模板。然后我使用相同的视图模板在gsp页面中设置样式,以便在浏览器中进行预览
包含嵌套模板的模板低于样式
<html>
<head>
<style type="text/css" media="print"></style>
</head>
<body>
<g:render template="depositStatement"/>
</body>
</html>
这在运行应用程序时有效,但在运行集成测试时不起作用。
Failure: |
Print Deposit Request(com.srm.billing.BillingPaymentRequestControllerIntegrationSpec)
|
org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Error executing tag <g:render>: null
at org.codehaus.groovy.grails.web.pages.GroovyPage.throwRootCause(GroovyPage.java:527)
at org.codehaus.groovy.grails.web.pages.GroovyPage.invokeTag(GroovyPage.java:470)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at C__Development_Grails36_sales_revenue_webapp_grails_app_views_billingPaymentRequest__printDepositStatement_gsp.run_closure1(_printDepositStatement.gsp:93)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at groovy.lang.Closure.call(Closure.java:423)
at groovy.lang.Closure.call(Closure.java:417)
at org.codehaus.groovy.grails.web.taglib.GroovyPageTagBody.executeClosure(GroovyPageTagBody.java:206)
at org.codehaus.groovy.grails.web.taglib.GroovyPageTagBody.captureClosureOutput(GroovyPageTagBody.java:108)
at org.codehaus.groovy.grails.web.taglib.GroovyPageTagBody.call(GroovyPageTagBody.java:219)
at org.codehaus.groovy.grails.plugins.web.taglib.SitemeshTagLib.captureTagContent(SitemeshTagLib.groovy:49)
at org.codehaus.groovy.grails.plugins.web.taglib.SitemeshTagLib$_closure3.doCall(SitemeshTagLib.groovy:157)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at groovy.lang.Closure.call(Closure.java:423)
at org.codehaus.groovy.grails.web.pages.GroovyPage.invokeTagLibClosure(GroovyPage.java:501)
at org.codehaus.groovy.grails.web.pages.GroovyPage.invokeTag(GroovyPage.java:419)
at C__Development_Grails36_sales_revenue_webapp_grails_app_views_billingPaymentRequest__printDepositStatement_gsp.run(_printDepositStatement.gsp:94)
at org.codehaus.groovy.grails.web.pages.GroovyPageWritable.doWriteTo(GroovyPageWritable.java:217)
at org.codehaus.groovy.grails.web.pages.GroovyPageWritable.writeTo(GroovyPageWritable.java:128)
at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer.makeTemplate(GroovyPagesTemplateRenderer.java:219)
at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer.render(GroovyPagesTemplateRenderer.java:105)
at org.codehaus.groovy.grails.plugins.web.taglib.RenderTagLib$_closure7.doCall(RenderTagLib.groovy:364)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at groovy.lang.Closure.call(Closure.java:423)
at org.codehaus.groovy.grails.web.pages.GroovyPage.captureTagOutput(GroovyPage.java:586)
at org.codehaus.groovy.grails.web.util.TagLibraryMetaUtils.registerMethodMissingForTags_closure3(TagLibraryMetaUtils.groovy:55)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at com.srm.billing.BillingPaymentRequestService.renderOutput(BillingPaymentRequestService.groovy:656)
at com.srm.billing.BillingPaymentRequestService.getOrCreateBillingDepositRequest(BillingPaymentRequestService.groovy:94)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:708)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644)
at com.srm.billing.BillingPaymentRequestControllerIntegrationSpec.Print Deposit Request(BillingPaymentRequestControllerIntegrationSpec.groovy:73)
Caused by: java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:333)
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:988)
at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer.generateScaffoldedTemplate(GroovyPagesTemplateRenderer.java:248)
at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer.access$300(GroovyPagesTemplateRenderer.java:64)
at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer$1$1.updateValue(GroovyPagesTemplateRenderer.java:164)
at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer$1$1.updateValue(GroovyPagesTemplateRenderer.java:135)
at grails.util.CacheEntry.getValue(CacheEntry.java:141)
at grails.util.CacheEntry.getValue(CacheEntry.java:81)
at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer.findAndCacheTemplate(GroovyPagesTemplateRenderer.java:132)
at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer.render(GroovyPagesTemplateRenderer.java:100)
at org.codehaus.groovy.grails.plugins.web.taglib.RenderTagLib$_closure7.doCall(RenderTagLib.groovy:364)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at groovy.lang.Closure.call(Closure.java:423)
at org.codehaus.groovy.grails.web.pages.GroovyPage.invokeTagLibClosure(GroovyPage.java:501)
at org.codehaus.groovy.grails.web.pages.GroovyPage.invokeTag(GroovyPage.java:419)
... 36 more
|Completed 3 integration tests, 1 failed in 0m 3s
答案 0 :(得分:1)
这并不意味着render标记为null,你的gsp有空指针异常,所以检查你的第二个gsp是否有可能的NPE。只是为了验证它不是渲染标记问题,你可以删除你的第二个gsp中的所有东西并且应该修复它,这将证明渲染不是问题,然后找出NPE的原因