0

We have annotated JSF 2 managed beans with @ManagedBean and @ViewScoped. Then in our Spring WebFlow flow.xml files; state change definitions like on-start and on-entry started complaining about it can not find out managed bean in any scope.

Jul 22, 2014 11:04:43 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jul 22, 2014 11:04:43 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jul 22, 2014 11:04:43 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 32586 ms
Jul 22, 2014 11:05:01 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [springMVCServlet] in context with path [/opp] threw exception [Request processing failed; nested exception is org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [AnnotatedAction@1e4c320 targetAction = [EvaluateAction@1c6a657 expression = serviceProviderSubscriptionBB.loadServiceProviderSubscription(subscriptionHeaderId), resultExpression = [null]], attributes = map[[empty]]] in state 'null' of flow 'service-provider-subscription' -- action execution attributes were 'map[[empty]]'] with root cause
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Property or field 'serviceProviderSubscriptionBB' cannot be found on object of type 'org.springframework.webflow.engine.impl.RequestControlContextImpl' - maybe not public?
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:215)
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:85)
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:78)
    at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:48)
    at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:84)
    at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:114)
    at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:105)
    at org.springframework.binding.expression.spel.SpringELExpression.getValue(SpringELExpression.java:84)
    at org.springframework.webflow.action.EvaluateAction.doExecute(EvaluateAction.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:154)
    at org.springframework.webflow.engine.Flow.start(Flow.java:526)
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:368)
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:223)



<on-start>

    <evaluate
        expression="serviceProviderSubscriptionBB.loadServiceProviderSubscription(subscriptionHeaderId)" />

</on-start>

Another problem we are facing is; destruction callbacks on @ViewScoped beans are never being called. We obtain new bean instance in each different JSF view but we have no clue about the old ones and dependent beans injected within them.

Can anyone help?

Thanks.

mrtbykkl
  • 1
  • 1
  • Which `@ViewScoped` are you using ? You cannot use CDI view scope with a JSF bean. Plus you need to name your managed bean or declare and name it in the bean.xml file. Instead of JSF's `@ManagedBean` use CDI's `@Named`, because the former is destined to be deprecated. –  Jul 22 '14 at 19:46
  • Show the code as to where its failing. – Prasad Jul 22 '14 at 19:54
  • javax.faces.bean.ViewScoped. If we use @Named, can we make it available only in JSF view survives? And can we access those beans in state change definitions (on-start, on-entry, on-render, on-exit etc) of WebFlow flow xml files? – mrtbykkl Jul 22 '14 at 19:55
  • @mrtbykkl I have never worked with spring so can't advice you much, but can tell for sure that CDI's beans are more accessible/exposed than JSF's managed beans. You should use CDI for any kind of framework integration job. Answer to your first question : yes, but use `javax.faces.view.ViewScoped` instead of `javax.faces.bean.ViewScoped`. –  Jul 22 '14 at 20:38

1 Answers1

1

Flow files only knows how to work with Spring Beans.

You can annotate your ManagedBean with @Component('serviceProviderSubscriptionBB') and let spring deal with it, or you could declare the managed bean direct on the flow <var name="serviceProviderSubscriptionBB" class="the full name of your class"/>, this way your class will be available throughout your entire flow.

Hope it helps!

squallsv
  • 482
  • 2
  • 11