Spring Web Flow流程镜

时间:2015-05-06 17:47:22

标签: spring spring-webflow-2

我有一个使用Spring Webflow 2.0的应用程序(在使用Spring 2.5.7的应用程序中)。

大部分流程都是在很久以前创建的,并且除了偶然的,看似随机的错误外,工作正常。

错误每天发生几次,并引发以下异常:

ognl.NoSuchPropertyException:org.springframework.webflow.engine.impl.RequestControlContextImpl.project

"项目"是我们添加到流量计的属性。

流程定义文件如下所示

<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/webflow
                      http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
    <on-start>
    <set name="flowScope.projectId" value="requestParameters.projectId" type="java.lang.Long"/>
    <set name="flowScope.modify" value="requestParameters.modify" type="java.lang.Boolean"/>
    <set name="flowScope.modelNameSpace" value="requestParameters.modelNameSpace" type="java.lang.String"/>
    <evaluate expression="getProjectPutInFlowScopeRedirectToRecentProjectifNullAction"/>
</on-start>

<action-state id="SET_SITE_ON_FLOW">
    <set name="flowScope.site" value="flowScope.project.site"/>
    <transition to="PROJECT_ADDRESS_PRESENT"/>
</action-state>
...

Action getProjectPutInFlowScopeRedirectToRecentProjectifNullAction从流中获取projectId,然后查找项目。

它声明存在projectId,然后在我们的数据库中查找项目。如果项目为null,则抛出另一个异常。因此,此操作可确保属性&#34; project&#34;在Spring Web Flow继续下一步之前,它不是null。

当用户单击或尝试异常访问流时,不会发生此错误。当从正常工作的链接启动流时会发生这种情况。

这是完整的堆栈跟踪。

    StackTrace: org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [AnnotatedAction@232e860e targetAction = [SetAction@4363132d name = flowScope.site, value = project.site, type = [null]], attributes = map[[empty]]] in state 'SET_SITE_ON_FLOW' of flow 'trace-over-aerial-image' -- action execution attributes were 'map[[empty]]'
        at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:60)
        at org.springframework.webflow.engine.ActionState.doEnter(ActionState.java:101)
        at org.springframework.webflow.engine.State.enter(State.java:194)
        at org.springframework.webflow.engine.Flow.start(Flow.java:535)
        at org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:364)
        at org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:222)
        at org.springframework.webflow.executor.FlowExecutorImpl.launchExecution(FlowExecutorImpl.java:140)
        at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:193)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
        at org.springframework.security.securechannel.ChannelProcessingFilter.doFilterHttp(ChannelProcessingFilter.java:116)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
        at org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at com.REMOVED.partner.security.PartnerPageAccessRegulator.doFilter(PartnerPageAccessRegulator.java:102)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.providers.anonymous.AnonymousProcessingFilter.doFilterHttp(AnonymousProcessingFilter.java:105)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:278)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at com.REMOVED.servlet.AnalyticsFilter.doFilter(AnalyticsFilter.java:59)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at com.REMOVED.billing.servlet.BillingSystemModelAttributeFilter.executeFilter(BillingSystemModelAttributeFilter.java:77)
        at com.REMOVEDservlet.AbstractModelAttributeFilter.doFilter(AbstractModelAttributeFilter.java:32)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at com.REMOVED.servlet.AppOrFrontEndSiteFilter.doFilter(AppOrFrontEndSiteFilter.java:61)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at com.REMOVED.partner.servlet.PartnerFilter.doFilter(PartnerFilter.java:117)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at com.REMOVED.servlet.GlobalModelFilter.doFilter(GlobalModelFilter.java:94)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.concurrent.ConcurrentSessionFilter.doFilterHttp(ConcurrentSessionFilter.java:99)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
        at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:190)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.binding.expression.PropertyNotFoundException: Property not found
        at org.springframework.binding.expression.ognl.OgnlExpression.getValue(OgnlExpression.java:87)
        at org.springframework.webflow.action.SetAction.doExecute(SetAction.java:75)
        at org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188)
        at org.springframework.webflow.execution.AnnotatedAction.execute(AnnotatedAction.java:145)
        at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51)
        ... 80 more
Caused by: ognl.NoSuchPropertyException: org.springframework.webflow.engine.impl.RequestControlContextImpl.project
        at ognl.ObjectPropertyAccessor.getProperty(ObjectPropertyAccessor.java:122)
        at org.springframework.webflow.expression.WebFlowOgnlExpressionParser$RequestContextPropertyAccessor.getProperty(WebFlowOgnlExpressionParser.java:118)
        at ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1657)
        at ognl.ASTProperty.getValueBody(ASTProperty.java:92)
        at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
        at ognl.SimpleNode.getValue(SimpleNode.java:210)
        at ognl.ASTChain.getValueBody(ASTChain.java:109)
        at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
        at ognl.SimpleNode.getValue(SimpleNode.java:210)
        at ognl.Ognl.getValue(Ognl.java:333)
        at org.springframework.binding.expression.ognl.OgnlExpression.getValue(OgnlExpression.java:85)
        ... 84 more

1 个答案:

答案 0 :(得分:0)

也许用户会话超时?不确定此语法是否适用于Spring Webflow 2.0但请尝试此

分开<evaluate expression="getProjectPutInFlowScopeRedirectToRecentProjectifNullAction"/>

到(就在开始标记的末尾之外)

  <decision-state id="chkNullProject">
        <on-entry>
            <set name="flowScope.project" value="someService.findMyProject(flowScope.projectId)"/>
        </on-entry>

        <if test="flowScope.project != null" then="SET_SITE_ON_FLOW" else="redirectToRecentProject"/>
  </decision-state>

  <action-state id="SET_SITE_ON_FLOW">
    <set name="flowScope.site" value="flowScope.project.site"/>
    <transition to="PROJECT_ADDRESS_PRESENT"/>
  </action-state>

  <end-state id="redirectToRecentProject" view="externalRedirect:/projects/id/#{flowScope.recentProjectId}"/>    

看看是否会导致间歇性异常行为消失。

还会创建一个FlowExecutionListenerAdapter,以便在发生此行为时进一步调查(RequestContext上下文)的内容。

Catch "dead" session in Spring webflow