Webflow and conversation/flow scoped services

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Webflow and conversation/flow scoped services

Timo Pulkkinen
Hi,

This most probably is a beginner question, but here comes:

How/When should I inject services with a scope of "conversation" or  
"flow" into a controller, or should I use a different approach? When  
I simply change the scope of a service from "session" to  
"conversation", without altering the controller code, I get the  
following exception:

-- clip --

Message: No flow execution context is bound to this thread
Caused by: Error creating bean with name 'myService': Scope  
'conversation' is not active for the current thread; consider  
defining a scoped proxy for this bean if you intend to refer to it  
from a singleton; nested exception is  
java.lang.IllegalStateException: No flow execution context is bound  
to this thread

Stack trace:

org.springframework.beans.factory.BeanCreationException: Error  
creating bean with name 'myService': Scope 'conversation' is not  
active for the current thread; consider defining a scoped proxy for  
this bean if you intend to refer to it from a singleton; nested  
exception is java.lang.IllegalStateException: No flow execution  
context is bound to this thread Caused by:  
java.lang.IllegalStateException: No flow execution context is bound  
to this thread at org.springframework.util.Assert.state(Assert.java:
354) at  
org.springframework.webflow.execution.FlowExecutionContextHolder.getFlow
ExecutionContext(FlowExecutionContextHolder.java:51) at  
org.springframework.webflow.config.scope.AbstractWebFlowScope.getFlowExe
cutionContext(AbstractWebFlowScope.java:109) at  
org.springframework.webflow.config.scope.ConversationScope.getScope
(ConversationScope.java:31) at  
org.springframework.webflow.config.scope.AbstractWebFlowScope.get
(AbstractWebFlowScope.java:51) at  
org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:284) at  
org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:161) at  
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
tory.autowireByName(AbstractAutowireCapableBeanFactory.java:829) at  
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
tory.populateBean(AbstractAutowireCapableBeanFactory.java:776) at  
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
tory.createBean(AbstractAutowireCapableBeanFactory.java:425) at  
org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:269) at  
org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:161) at  
org.springframework.context.support.AbstractApplicationContext.getBean
(AbstractApplicationContext.java:642)
...

-- clip --


The service is introduced as follows:

-- clip --
import org.springframework.context.*

class MyController {
        def myService

      def index = {
        }

      def myOwnFlow = {
                ...
        }
-- clip --



Cheers,
Timo

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Webflow and conversation/flow scoped services

graemer
With flows you don't need to inject. Just reference the service by
name within your flow actions and  you can invoke them

Cheers

On 10/5/07, Timo Pulkkinen <[hidden email]> wrote:

> Hi,
>
> This most probably is a beginner question, but here comes:
>
> How/When should I inject services with a scope of "conversation" or
> "flow" into a controller, or should I use a different approach? When
> I simply change the scope of a service from "session" to
> "conversation", without altering the controller code, I get the
> following exception:
>
> -- clip --
>
> Message: No flow execution context is bound to this thread
> Caused by: Error creating bean with name 'myService': Scope
> 'conversation' is not active for the current thread; consider
> defining a scoped proxy for this bean if you intend to refer to it
> from a singleton; nested exception is
> java.lang.IllegalStateException: No flow execution context is bound
> to this thread
>
> Stack trace:
>
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'myService': Scope 'conversation' is not
> active for the current thread; consider defining a scoped proxy for
> this bean if you intend to refer to it from a singleton; nested
> exception is java.lang.IllegalStateException: No flow execution
> context is bound to this thread Caused by:
> java.lang.IllegalStateException: No flow execution context is bound
> to this thread at org.springframework.util.Assert.state(Assert.java:
> 354) at
> org.springframework.webflow.execution.FlowExecutionContextHolder.getFlow
> ExecutionContext(FlowExecutionContextHolder.java:51) at
> org.springframework.webflow.config.scope.AbstractWebFlowScope.getFlowExe
> cutionContext(AbstractWebFlowScope.java:109) at
> org.springframework.webflow.config.scope.ConversationScope.getScope
> (ConversationScope.java:31) at
> org.springframework.webflow.config.scope.AbstractWebFlowScope.get
> (AbstractWebFlowScope.java:51) at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean
> (AbstractBeanFactory.java:284) at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean
> (AbstractBeanFactory.java:161) at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
> tory.autowireByName(AbstractAutowireCapableBeanFactory.java:829) at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
> tory.populateBean(AbstractAutowireCapableBeanFactory.java:776) at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
> tory.createBean(AbstractAutowireCapableBeanFactory.java:425) at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean
> (AbstractBeanFactory.java:269) at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean
> (AbstractBeanFactory.java:161) at
> org.springframework.context.support.AbstractApplicationContext.getBean
> (AbstractApplicationContext.java:642)
> ...
>
> -- clip --
>
>
> The service is introduced as follows:
>
> -- clip --
> import org.springframework.context.*
>
> class MyController {
>         def myService
>
>         def index = {
>         }
>
>         def myOwnFlow = {
>                 ...
>         }
> -- clip --
>
>
>
> Cheers,
> Timo
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Graeme Rocher
Grails Project Lead
http://grails.org

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email