Grails с формой выдает исключение NullPointerException

#java #grails #grails-2.0 #grails-webflow

#java #grails #grails-2.0 #grails-webflow

Вопрос:

Я использую Grails 2.3.11. Включил механизм предотвращения дублирования отправки формы с помощью withForm предложения using . Токен передан правильно. Дело в том, что при обработке запроса предложение withForm выдает исключение NullPointerException. Форма была отправлена из веб-потока Grails.

Код потока

 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 {
    }
}
 

С помощью этого фрагмента кода исключение 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 вызывает метод withForm(closure) из основного проекта grails.

Комментарии:

1. в c.b.c.c.CampController $_closure14.doCall(CampController.groovy:435) что там происходит дальше?

2. Это начало вызова withForm { } .

3. Есть какой-нибудь намек @GraemeRocher? Я вижу ваш вклад в класс SynchronizerTokensHolder , который отвечает за обработку закрытия withForm.