Announcement Announcement Module
Collapse
No announcement yet.
Multithreading issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multithreading issue

    I regularly get errors in my flows when two threads hit a flow at the same time and i am stumped as to what I am doing wrong. here's a typical example

    Code:
    <var name="handsetModel" class="com.***.***.binding.HandsetModel"/>
    
    <on-start>
    	<set name="flowScope.cart" value="externalContext.sessionMap.cart" type="com.***.***.cart.ShoppingCart"/>
    </on-start>
    
    <action-state id="decideOnActivityType">
    	<evaluate expression="flowScope.cart.getActivityTypeString()" result-type="string"/>
    	<transition on="contractHandset" to="decideOnStartState"/>
    	<transition on="paygHandset" to="addPaygHandset"/>
    </action-state>
    Error in eclipse:
    Code:
    java.lang.NullPointerException: target is null for method getActivityTypeString
    	at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:862)
    	at ognl.ASTMethod.getValueBody(ASTMethod.java:73)
    	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)
    	at org.springframework.webflow.action.EvaluateAction.doExecute(EvaluateAction.java:77)
    	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)
    	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.webflow.mvc.servlet.FlowController.handleRequest(FlowController.java:174)
    	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    	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:627)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
    	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    	at java.lang.Thread.run(Thread.java:595)
    Error in Browser:
    Code:
    exception 
    
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [AnnotatedAction@10fba68 targetAction = [EvaluateAction@1970991 expression = flowScope.cart.getActivityTypeString(), resultExposer = [null]], attributes = map[[empty]]] in state 'decideOnActivityType' of flow 'contractHandsetSale' -- action execution attributes were 'map[[empty]]'
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:583)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    
    
    root cause 
    
    org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [AnnotatedAction@10fba68 targetAction = [EvaluateAction@1970991 expression = flowScope.cart.getActivityTypeString(), resultExposer = [null]], attributes = map[[empty]]] in state 'decideOnActivityType' of flow 'contractHandsetSale' -- action execution attributes were 'map[[empty]]'
    	org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:60)
    	org.springframework.webflow.engine.ActionState.doEnter(ActionState.java:101)
    	org.springframework.webflow.engine.State.enter(State.java:194)
    	org.springframework.webflow.engine.Flow.start(Flow.java:535)
    	org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:364)
    	org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:222)
    	org.springframework.webflow.executor.FlowExecutorImpl.launchExecution(FlowExecutorImpl.java:140)
    	org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:193)
    	org.springframework.webflow.mvc.servlet.FlowController.handleRequest(FlowController.java:174)
    	org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    
    
    root cause 
    
    java.lang.NullPointerException: target is null for method getActivityTypeString
    	ognl.OgnlRuntime.callMethod(OgnlRuntime.java:862)
    	ognl.ASTMethod.getValueBody(ASTMethod.java:73)
    	ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    	ognl.SimpleNode.getValue(SimpleNode.java:210)
    	ognl.ASTChain.getValueBody(ASTChain.java:109)
    	ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    	ognl.SimpleNode.getValue(SimpleNode.java:210)
    	ognl.Ognl.getValue(Ognl.java:333)
    	org.springframework.binding.expression.ognl.OgnlExpression.getValue(OgnlExpression.java:85)
    	org.springframework.webflow.action.EvaluateAction.doExecute(EvaluateAction.java:77)
    	org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188)
    	org.springframework.webflow.execution.AnnotatedAction.execute(AnnotatedAction.java:145)
    	org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51)
    	org.springframework.webflow.engine.ActionState.doEnter(ActionState.java:101)
    	org.springframework.webflow.engine.State.enter(State.java:194)
    	org.springframework.webflow.engine.Flow.start(Flow.java:535)
    	org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:364)
    	org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:222)
    	org.springframework.webflow.executor.FlowExecutorImpl.launchExecution(FlowExecutorImpl.java:140)
    	org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:193)
    	org.springframework.webflow.mvc.servlet.FlowController.handleRequest(FlowController.java:174)
    	org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    I am using webflow 2.0.8 and ognl 2.6.9. Hitting the flow in a single threaded environment I never get any issues at all, but quite often i get exceptions firing more than one thread.

  • #2
    Extra info

    I'm starting to clutch at straws with this so i attempted the following. Rather than access the cart from session map directly in the flow i call a method that returns the cart.
    Code:
    <var name="handsetModel" class="com.***.***.binding.HandsetModel"/>
    <on-start>
    	<set name="flowScope.cart" value="proofActions.getCart(flowRequestContext)" type="com.***.***.cart.ShoppingCart"/>
    </on-start>
    <action-state id="decideOnActivityType">
    	<evaluate expression="proofActions.isContractHandset(flowScope.cart)"/>
    	<transition on="yes" to="decideOnStartState"/>
    	<transition on="no" to="addPaygHandset"/>
    </action-state>
    Method code:
    Code:
        public ShoppingCart getCart(RequestContext context){
            log.info("Method call - getCart()");
            ExternalContext ec = context.getExternalContext();
            log.info("External context: "+ec);
            SharedAttributeMap sessionMap = ec.getSessionMap();
            log.info("SessionMap: "+sessionMap);
            ShoppingCart cart = (ShoppingCart) sessionMap.get("cart");
            log.info("Cart retrieved from session: "+cart);
            return cart;
        }
    Here is the error that appears in the browser:
    Code:
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [AnnotatedAction@a5ce92 targetAction = [SetAction@52744 name = flowScope.cart, value = proofActions.getCart(flowRequestContext), type = ShoppingCart], attributes = map[[empty]]] in state 'null' of flow 'contractHandsetSale' -- action execution attributes were 'map[[empty]]'
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:583)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [AnnotatedAction@a5ce92 targetAction = [SetAction@52744 name = flowScope.cart, value = proofActions.getCart(flowRequestContext), type = ShoppingCart], attributes = map[[empty]]] in state 'null' of flow 'contractHandsetSale' -- action execution attributes were 'map[[empty]]'
    	org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:60)
    	org.springframework.webflow.engine.ActionList.execute(ActionList.java:155)
    	org.springframework.webflow.engine.Flow.start(Flow.java:534)
    	org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:364)
    	org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:222)
    	org.springframework.webflow.executor.FlowExecutorImpl.launchExecution(FlowExecutorImpl.java:140)
    	org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:193)
    	org.springframework.webflow.mvc.servlet.FlowController.handleRequest(FlowController.java:174)
    	org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    java.lang.NullPointerException
    	org.springframework.webflow.expression.WebFlowOgnlExpressionParser$RequestContextPropertyAccessor.getProperty(WebFlowOgnlExpressionParser.java:92)
    	ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1657)
    	ognl.ASTProperty.getValueBody(ASTProperty.java:92)
    	ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    	ognl.SimpleNode.getValue(SimpleNode.java:210)
    	ognl.ASTMethod.getValueBody(ASTMethod.java:71)
    	ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    	ognl.SimpleNode.getValue(SimpleNode.java:210)
    	ognl.ASTChain.getValueBody(ASTChain.java:109)
    	ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    	ognl.SimpleNode.getValue(SimpleNode.java:210)
    	ognl.Ognl.getValue(Ognl.java:333)
    	org.springframework.binding.expression.ognl.OgnlExpression.getValue(OgnlExpression.java:85)
    	org.springframework.webflow.action.SetAction.doExecute(SetAction.java:75)
    	org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188)
    And here is the error that appears in Eclipse:
    Code:
    INFO  Method call - getCart()
    INFO  External context: [email protected]2
    ERROR Servlet.service() for servlet phoenixWebApp threw exception
    java.lang.NullPointerException
    	at org.springframework.webflow.expression.WebFlowOgnlExpressionParser$RequestContextPropertyAccessor.getProperty(WebFlowOgnlExpressionParser.java:92)
    	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.ASTMethod.getValueBody(ASTMethod.java:71)
    	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)
    	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)
    	at org.springframework.webflow.engine.ActionList.execute(ActionList.java:155)
    	at org.springframework.webflow.engine.Flow.start(Flow.java:534)
    	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.webflow.mvc.servlet.FlowController.handleRequest(FlowController.java:174)
    	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    	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:627)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
    	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    	at java.lang.Thread.run(Thread.java:595)
    INFO  SessionMap: map['cart' -> com.***.cart.ShoppingCart@19d0cf0]
    INFO  Cart retrieved from session: com.***.cart.ShoppingCart@19d0cf0
    To me it looks like the first thread is calling the method, but the second thread is blowing up when attempting to call it. If anyone can give me any indication as to what's causing this it would be greatly appreciated.

    thanks

    Comment


    • #3
      Update

      Here is my last ditched attempt to get a response, hopefully this post will show a little clearer where things are failing:

      flowScope.cart is null in the following code when 2 threads are hitting the flow at exactly the same time

      Code:
      <var name="handsetModel" class="com.***.***.binding.HandsetModel"/>
      
      <on-start>
      	<set name="flowScope.cart" value="externalContext.sessionMap.cart" type="com.***.***.cart.ShoppingCart"/>
      </on-start>
      
      <action-state id="decideOnActivityType">
      	<evaluate expression="handsetActions.isContractHandset(flowScope.cart)"/>
      	<transition on="yes" to="decideOnStartState"/>
      	<transition on="no" to="addPaygHandset"/>
      </action-state>
      here is the isContracthandset method that is called in the 'decideOnActivityType' action state:
      Code:
      public boolean isContractHandset(ShoppingCart cart) {
      	if(cart == null){
      	    log.info("cart is null");
      	}
      	log.info("Method call - isContractHandset(): cart "+cart);
      	boolean isContractHandset = false;
      	if("contractHandset".equals(cart.getActivityTypeString())){
      	    isContractHandset = true;
      	}
      	return isContractHandset;
      }
      and here is the output from the log:
      Code:
      INFO  Session created ID: 212DFC605416E21C90791898EAD32A1C
      INFO  Object added to sssion: Session ID: 212DFC605416E21C90791898EAD32A1C cart com.***.***.cart.ShoppingCart@14c7cd
      INFO  Session created ID: 30C4695F2D1737D06B02F5E5B992258E
      INFO  Object added to sssion: Session ID: 30C4695F2D1737D06B02F5E5B992258E cart com.***.***.cart.ShoppingCart@497536
      INFO  Refreshing org.springframework.web.context.support.GenericWebApplicationContext@b4ac5c: display name [Flow ApplicationContext [contractHandsetSale]]; startup date [Wed Aug 19 09:41:12 GMT 2009]; parent: org.springframework.web.context.support.XmlWebApplicationContext@1bb60ad
      INFO  Bean factory for application context [org.springframework.web.context.support.GenericWebApplicationContext@b4ac5c]: org.springframework.beans.factory.support.DefaultListableBeanFactory@70856b
      INFO  Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@70856b: defining beans [org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,messageSource]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@270fc4
      INFO  cart is null
      INFO  Method call - isContractHandset(): cart com.***.***.cart.ShoppingCart@14c7cd
      INFO  Method call - isContractHandset(): cart null
      I have a implemented an HttpSessionAttributeListener so I can confim that there are two shopping carts in separate sessions. It appears that I can only replicate this issue after I have restarted the server and submitted the first requests. Anybody?

      Comment


      • #4
        Odd. This looks similar to this issue which was fixed with SWF 2.0.6. Maybe something similar was introduced in 2.0.8? I'd really like to know if it affects 2.0.7 as well. I'd suggest opening a JIRA ticket for this.

        Comment


        • #5
          Thanks for the reply. I was originally using 2.0.5 and updated to 2.0.8 after seeing the JIRA you mention. I then rolled back to 2.0.6, but still got the same problem so I suspect this is a different issue.

          Comment


          • #6
            Just for kicks, can you increase the max-executions for your flow-execution-repository to 2 or more and see if the issue still occurs?

            Comment


            • #7
              JIRA raised

              I have raised the max executions to 2, but problem persists. Here's a link to the JIRA

              Comment


              • #8
                Anyone explain this behaviour?

                I decided to pass in the shopping cart to the top level flow using a flow handler which is fine in a single threaded environment.
                flow:
                Code:
                <input name="cart" type="cart.ShoppingCart" required="true" value="flowScope.cart"/>
                
                <action-state id="decideOnActivityType">
                	<evaluate expression="handsetActions.getActivityType(flowScope.cart.userSessionModel)"/>
                	<transition on="contractHandset" to="decideOnStartState"/>
                	<transition on="paygHandset" to="addPaygHandset"/>
                </action-state>
                flow handler method:
                Code:
                    public MutableAttributeMap createExecutionInputMap(HttpServletRequest request) {
                        
                        MutableAttributeMap map = null;
                        
                        HttpSession session = request.getSession();
                        
                        synchronized (session) {
                        	ShoppingCart cart = (ShoppingCart) session.getAttribute("cart");
                        	if(cart != null){
                        		map = new LocalAttributeMap();
                        		map.put("cart", cart);
                        	}
                        }
                
                        return map;
                    }
                Problems occur when two threads hit the flow at once and I get the following error:
                Code:
                ognl.OgnlException: source is null for getProperty(null, "userSessionModel")
                	at ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1652)
                	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.ASTMethod.getValueBody(ASTMethod.java:71)
                	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)
                	at org.springframework.webflow.action.EvaluateAction.doExecute(EvaluateAction.java:77)
                	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)
                	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.doPost(FrameworkServlet.java:511)
                The error is complaining that flow.cart is null when trying to access userSessionModel, but how is this possible because the input mapping 'cart' is set as required and if it was null it would throw a FlowInputMappingException.

                This is a show stopper and I have no idea what to do.

                Comment


                • #9
                  Hi guys,
                  I have a similar issue like above,where my junit throws the below error.

                  org.springframework.webflow.execution.ActionExecut ionException: Exception thrown executing [AnnotatedAction@115126e targetAction = [FlightSearchAction@6d2380 formObjectName = 'formObject', formObjectClass = [null], formObjectScope = Flow], attributes = map['method' -> 'setupForm']] in state 'null' of flow 'test-booking-flow' -- action execution attributes were 'map[[empty]]'

                  My code:
                  public void testStartFlow() throws Exception {
                  ExternalContext context = new MockExternalContext();
                  // MutableAttributeMap reqScope = mockReqCxt.getRequestScope();
                  test.setFormObjectName("searchForm");
                  test.setFormObjectClass(com.sia.saa.booking.form.F lightSearchForm.class);
                  test.setFormObjectScope(ScopeType.FLOW);
                  mockReqCxt.setAttribute("setupForm", test.setupForm(mockReqCxt));
                  // reqScope.put("setupForm", test.setupForm(mockReqCxt));
                  startFlow(attributeMap, context);
                  assertCurrentStateEquals("searchHome");
                  }

                  My Question is:
                  How do I make the setupForm method available in scope during testing.It seems this method is throwing null.

                  My configuration file:
                  <on-start>
                  <evaluate expression="flightSearchAction.setupForm" />
                  </on-start>

                  Comment

                  Working...
                  X