3
votes

I am using spring webflow, this is my flow

<view-state id="welcome">
    <transition on="emailEntered" to="checkEmail"></transition>
</view-state>
<decision-state id="checkEmail">
    <if test="alta.checkEmail(requestParameters.email)"
    then="okState"
    else="errorState"/>
</decision-state>
<view-state id="okState"/>
<view-state id="errorState"/>

I have enabled auto-scanning in my servlet-context:

<context:component-scan base-package="com.me.myproj" />

I get a org.springframework.binding.expression.PropertyNotFoundException: Property not found error for state checkEmail. The problem is that it doesn't recognize my 'alta' bean, this is my Alta class (placed in com.me.myproj):

@Component
public class Alta {
    public Alta(){
        System.out.println("constructor ok");
    }
    public boolean checkEmail(String email){

        return "[email protected]".equals(email);
    }

}

If I explicitly create the bean:

<bean id="alta" class="com.me.myproj.Alta"/>

Then it works fine. So it seems that flow context doesn't recognize auto-scanned components, although alta is instanciated (as I saw when I debugged).

What can I do to avoid declaring explictly all beans involved in my flow?

2
is it resolved? what is the fix?Dev G
No, sorry, I didn't work on it anymore..de3

2 Answers

0
votes

Did you include

<context:annotation-config/>  

in your servlet-context.xml?

0
votes

When you explicitly create the bean in the XML you are naming the bean with name "alta" (id value). That is why you can execute methods from class Alta refering to "alta.checkEmail(...)".

<bean id="alta" class="com.me.myproj.Alta"/>

If you want to avoid XML declaration and use annotations only, you should specify that name in the annotation by just passing the name as argument [1]. For example:

@Component("alta")
public class Alta {
    public Alta(){
        System.out.println("constructor ok");
    }
    public boolean checkEmail(String email){

        return "[email protected]".equals(email);
    }
}

Hope this helps.

[1] http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/stereotype/Component.html