I am trying to configure a flowscope in jsf using a @FlowSoped bean, using a xml file called registration-flow inside the registration folder it works properly
HTML Code:
<flow-definition id="registration">
    <view id="registration">
        <vdl-document>/registration/registration.xhtml</vdl-document>
    </view>
    <flow-return id="taskReturnIndex">
        <from-outcome>/index</from-outcome>
    </flow-return>
    <flow-return id="taskDone">
        <from-outcome>/done</from-outcome>
    </flow-return>

    <flow-call id="taskSchedule">
        <flow-reference>
            <flow-id>schedule</flow-id>
        </flow-reference>
        <outbound-parameter>
            <name>nameparam</name>
            <value>#{registrationBean.name}</value>
        </outbound-parameter>
        <outbound-parameter>
            <name>surnameparam</name>
            <value>#{registrationBean.surname}</value>
        </outbound-parameter>
        <outbound-parameter>
            <name>registrationcode</name>
            <value>349CF0Y0122</value>
        </outbound-parameter>
    </flow-call>

</flow-definition>
But when i remove this and i try to configure it using a java class it doesn't work and i have Unable to find matching navigation case with from-view-id '/index.xhtml' for action 'registration' with outcome 'registration'

Code:
public class Registration implements Serializable{

    @Produces
    @FlowDefinition
    public Flow defineFlow(@FlowBuilderParameter FlowBuilder flowBuilder){

        String flowId= "registration";
        flowBuilder.id("", flowId);

        flowBuilder.viewNode(flowId, "/"+flowId+"/"+flowId+".xhtml")
                .markAsStartNode();
        flowBuilder.viewNode("confirm-id", "/"+flowId+"/confirm.xhtml");
        flowBuilder.viewNode("thanks-id", "/"+flowId+"/thanks.xhtml");

        flowBuilder.returnNode("taskReturnIndex").fromOutcome("/index");
        flowBuilder.returnNode("taskDone").fromOutcome("/done");

        flowBuilder.flowCallNode("taskSchedule")
                .flowReference("", "schedule")
                .outboundParameter("nameparam", "#{registrationBean.name}")
                .outboundParameter("surnameparam", "#{registrationBean.surname}")
                .outboundParameter("registrationcode", "349CF0Y0122");

        return flowBuilder.getFlow();

    }

}
It really looks like it doesn't get recognized as flowBean, i got the example from a book and it's the same so the code of the java class should be correct, why is it not working ?