springspring-mvcspring-webflowspring-webflow-2

Spring Webflow 2.4.2 missing start state


I just started adding Webflow to a Spring MVC project and I'm getting this compile error on my flow.xml component:

Start state is missing. Add at least one state to the flow

I found an identical post on SO from a year ago: webflow.xsd - Start state is missing. Add at least one state to the flow. No one responded to this question but I found it in the Jira repository for Spring Webflow: webflow.xsd - Start state is missing. Add at least one state to the flow. It is marked as Cannot Reproduce.

Here is an excerpt from my very simple webflow.xml.

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

    <on-start>
        <evaluate expression="recipeService.createRecipe(currentUser.name)" result="flowScope.recipe" />
    </on-start>

    <view-state id="basics" view="recipe/basics" model="recipe">
        <transition on="proceed" to="ingredients"></transition>
        <transition on="cancel" to="cancel"></transition>
    </view-state>

    ... more states ...

    <end-state id="end" view="recipe/end"/>
    <end-state id="cancel" view="recipe/end"/>

    </flow>

The documentation indicates that start-state is optional - the first view-state will be assumed to be the start. If I change the spring-webflow-2.4.xsd to 2.0 the error goes away, but then I get a different error if I attempt to use validation-hints on any of the view-state entries. "Basic1" and "Basic2" in the example below are validation groups on the recipe model.

<view-state id="basics" view="recipe/basics" model="recipe" validation-hints="'basic1,basic2'">

I'm using

I'm using java-based config for everything, but I don't think that is where the problem lies unless I have a mismatch in the versions that Webflow 2.4.2 requires? I can post my WebMvcConfig and WebFlowConfig or the pom.xml or any other info if that would help.

Any assistance would be greatly appreciated.

EDIT #1: excerpts from java config

    From WebFlowConfig.java: 
    @Bean
    public FlowDefinitionRegistry flowRegistry() {
        return getFlowDefinitionRegistryBuilder(flowBuilderServices())
            .setBasePath("/WEB-INF/views")
            .addFlowLocationPattern("/**/*-flow.xml")
            .build();               
    }

    From WebMvcConfig.java
    @Override
    public void addViewControllers(final ViewControllerRegistry registry) {
        super.addViewControllers(registry);
        registry.addViewController("/recipe/basics.htm");        
        registry.addViewController("/recipe/ingredients.htm");
        registry.addViewController("/recipe/instructions.htm");
        registry.addViewController("/recipe/optional.htm");
        registry.addViewController("/recipe/end.htm");
    }

Using 2.0 all of the pages are executed in the correct order.

EDIT #2

I forgot to mention that even with the 2.4 xsd compile error the webflow does get executed, same as in the post from a year ago. I also found this issue regarding STS: webflow config gives incorrect "Start state definition is missing." error. The indicated fix version is 3.3.0.M1 so I would assume (?) the fix is still included in STS 3.6.4.


Solution

  • I spent several hours trying everything I could think of, including replacing nearly everything in the pom.xml with the contents of the pom.xml from the booking-mvc sample project, which was not displaying this error in spite of also being set to version 2.4.2. Since webflow seems to be tied into Thymeleaf and Tiles (which I am not using) I thought there might be a dependency in those projects which would remove the error. There was not.

    So I went through the properties of the booking-mvc project and compared them to mine. The only relevant difference I could see was in the Spring | Web Flow Support. My project listed my recipe-flow.xml, but booking-mvc did not display its -flow.xml file. Once I removed my flow.xml file the error disappeared.

    enter image description here

    I have no idea how the file ended up in this config location and I can't find any documentation on what this property is for, but apparently it's a no-no, at least in my project. It took a while to get my pom.xml back in shape but the app is now working again.