Grails withForm给出了NullPointerException

时间:2016-10-14 06:32:17

标签: java grails grails-2.0 grails-webflow

我正在使用Grails 2.3.11。使用withForm子句包含重复表单提交预防机制。令牌已正确传递。事情是在处理请求时,withForm子句抛出NullPointerException。表单已从Grails Webflow内部提交。

流程代码

def editFlow = {
    initialize {
        [flow initialization code]
    }
    step1 {
        on("step1").to("step1")
        on("action1", doAction1Save).to("action1")
    }
}

流动作转化处理程序

def doAction1Save = { CommandObj commandObj ->
    withForm {
        [form handling process]
    }.invalidToken {
    }
}

使用此代码段,在withForm操作上抛出NullPointerException。

我已经检查过关闭传递给withForm,它工作得很好。通过调用{}.call()方法独立运行它。

任何人都可以指导我在哪里做错了吗?

异常堆栈跟踪

java.lang.NullPointerException
  at c.b.c.c.CampController.withForm(CampController.groovy)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
  at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)
  at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1003)
  at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
  at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
  at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
  at c.b.c.c.CampController$_closure14.doCall(CampController.groovy:435)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:272)
  at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:64)
  at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
  at org.codehaus.groovy.grails.webflow.engine.builder.ClosureInvokingAction.doExecute(ClosureInvokingAction.groovy:115)
  at org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188)
  at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51)
  at org.springframework.webflow.engine.support.ActionTransitionCriteria.test(ActionTransitionCriteria.java:82)
  at org.springframework.webflow.engine.Transition.canExecute(Transition.java:195)
  at org.springframework.webflow.engine.Transition.execute(Transition.java:211)
  at org.springframework.webflow.engine.impl.FlowExecutionImpl.execute(FlowExecutionImpl.java:391)
  at org.springframework.webflow.engine.impl.RequestControlContextImpl.execute(RequestControlContextImpl.java:214)
  at org.springframework.webflow.engine.TransitionableState.handleEvent(TransitionableState.java:119)
  at org.springframework.webflow.engine.Flow.handleEvent(Flow.java:555)
  at org.springframework.webflow.engine.impl.FlowExecutionImpl.handleEvent(FlowExecutionImpl.java:386)
  at org.springframework.webflow.engine.impl.RequestControlContextImpl.handleEvent(RequestControlContextImpl.java:210)
  at org.springframework.webflow.engine.ViewState.handleEvent(ViewState.java:230)
  at org.springframework.webflow.engine.ViewState.resume(ViewState.java:196)
  at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
  at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:259)
  at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:163)
  at org.codehaus.groovy.grails.webflow.execution.GrailsFlowExecutorImpl.resumeExecution(GrailsFlowExecutorImpl.java:74)
  at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
  at org.codehaus.groovy.grails.webflow.mvc.servlet.GrailsFlowHandlerAdapter.handle(GrailsFlowHandlerAdapter.java:53)
  at org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.doDispatch(GrailsDispatcherServlet.java:355)
  at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:851)
  at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
  at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:855)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
  at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
  at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:100)
  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:100)
  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:100)
  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
  at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
  at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
  at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:274)
  at io.undertow.servlet.handlers.ServletInitialHandler.dispatchToPath(ServletInitialHandler.java:209)
  at io.undertow.servlet.spec.RequestDispatcherImpl.forwardImpl(RequestDispatcherImpl.java:221)
  at io.undertow.servlet.spec.RequestDispatcherImpl.forwardImplSetup(RequestDispatcherImpl.java:147)
  at io.undertow.servlet.spec.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:111)
  at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:332)
  at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:297)
  at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:288)
  at org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.doFilterInternal(UrlMappingsFilter.java:217)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)
  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.executeFilterChainWithWrappedResponse(GrailsPageFilter.java:233)
  at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.obtainContent(GrailsPageFilter.java:208)
  at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.doFilter(GrailsPageFilter.java:153)
  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:69)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)
  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  at org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)
  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)
  at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
  at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
  at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
  at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)

第435行从grails核心项目调用withForm(closure)方法。

0 个答案:

没有答案