Search code examples
javaspringspring-mvcspring-webflow-2

Subflow invocation not working in Spring webflow


I am creating a ShoppingCart Application in Spring mvc.Here I have two flows for now.

  1. Registration Flow(flow id=registrationFlow)
  2. MailSender Flow(flow id=mailFlow)

When user registration data gets entered in DB successfully a mailSender flow(Subflow) will get triggered.

My Parent Flow is RegistrationFlow.

Please find below Subflow invocation code:

<!-- other navigation rules of parent flow -->

<subflow-state id="mailSenderFlow" subflow="mailFlow">
    <input name="userEmail" value="flowScope.regBean.userDTO.userMail"/>
    <transition on="finishMailFlow" to="checkMailFlowResult" />
</subflow-state>

<decision-state id="checkMailFlowResult">
    <if test="mailSender.mailConfirmation(currentEvent.attributes.mailFlowOutcome)"
        then="regSuccess" else="regConfirm" />
</decision-state>

<end-state id="regSuccess" view="/WEB-INF/view/regSuccess.jsp" />

Based on subflow outcome I have created a decision state which will take the control to regSuccess page or back to regConfirm page.

Please find below Subflow definition file:

    <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.4.xsd">

         <input name="userEmail" required="true" type="java.lang.String"/>

        <action-state id="mailSenderAction">
           <evaluate expression="mailSender.sendEmail(userEmail)" />
              <transition on="success" to="finishMailFlow" />
        </action-state>

        <end-state id="finishMailFlow">
            <output name="mailFlowOutcome" value="mail sending done"/>
        </end-state>
     </flow>

Now during subflow invocation time I am getting following exception :

  org.springframework.webflow.execution.FlowExecutionException: Exception  thrown in state 'mailSenderFlow' of flow 'registrationFlow'
  at  org.springframework.webflow.engine.impl.FlowExecutionImpl.wrap(FlowExecutionImpl.java:573)
  at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:263)
at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:253)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
Truncated. see log file for complete stacktrace

Caused By: org.springframework.expression.spel.SpelParseException: EL1041E:  After parsing a valid expression, there is still more data in the expression: 'sending'
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.doParseExpression(InternalSpelExpressionParser.java:130)
at org.springframework.expression.spel.standard.SpelExpressionParser.doParseExpression(SpelExpressionParser.java:60)
at org.springframework.expression.spel.standard.SpelExpressionParser.doParseExpression(SpelExpressionParser.java:32)
at org.springframework.expression.common.TemplateAwareExpressionParser.parseExpression(TemplateAwareExpressionParser.java:73)
at org.springframework.binding.expression.spel.SpringELExpressionParser.parseSpelExpression(SpringELExpressionParser.java:96)
Truncated. see log file for complete stacktrace>

Can anyone figure out the issue???


Solution

  • try with single quote inside your value:

    <output name="mailFlowOutcome" value="'mail sending done'"/>