gpt4 book ai didi

spring - G Render在集成测试中为null

转载 作者:行者123 更新时间:2023-12-02 15:25:23 26 4
gpt4 key购买 nike

当我运行集成测试并尝试呈现模板时,出现以下错误。模板的唯一部分是在第93行的其中渲染模板。我这样做的原因是要渲染一个模板,以将其转换为PDF,它包含一个样式模板,该模板称为 View 模板。 。然后使用同一 View 模板在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

最佳答案

这并不意味着render标签为空,您的gsp具有空指针异常,因此请检查第二个gsp是否存在NPE。只是为了确认其不是渲染标签问题,您可以从第二个gsp中删除所有东西,并且应该对其进行修复,这将证明渲染不是问题,然后找出导致NPE的原因

关于spring - G Render在集成测试中为null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28461445/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com