You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Boris Brönner <bo...@gmail.com> on 2013/10/08 16:05:00 UTC

CDI event propagation to ViewAccessScoped/ConversationScoped classes

Hello,

I have a database layer, that can be accessed by JSF and by REST. The
backing beans for JSF are ViewAccessScoped. The services for REST are
RequestScoped.

When creating an entity, from both JSF or REST, an event should be raised
to notify all possible clients (JSF, but also other clients listening e.g.
JMS events). Now a problem occurs. When I create an entity using the REST
interface the event is raised as expected.

However now WELD raises an ContextNotActiveException:

org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active
contexts for scope type
org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ViewAccessScoped

I get the same problem when using the ConversationScoped annotation. This
problem occurs always when using the REST interface, i.e. whether or not I
have an JSF page open.


Below you find a more detailed stack trace starting from the point where
the event is fired.It seems like Weld thinks there is such a bean, but in
the end then can't get a context.

What can I do here? Does the CODI implementation even work in this context?

If you need more information about my setup, let me know :)

Regards,
Boris

Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No
active contexts for scope type
org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationScoped
    at
org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:598)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at
org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:71)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at
org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at
de.dfki.asr.compass.ejb.project.OpenScenarioBean$Proxy$_$$_WeldClientProxy.handleEntityCreated(OpenScenarioBean$Proxy$_$$_WeldClientProxy.java)
[classes:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[rt.jar:1.7.0_11]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[rt.jar:1.7.0_11]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[rt.jar:1.7.0_11]
    at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_11]
    at
org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:264)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at
org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at
org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at
org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:260)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at
org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:170)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at
org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:51)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at
org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:154)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at
org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:241)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at
org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:229)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at
org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:207)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at
org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:569)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at
org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:564)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at org.jboss.weld.event.EventImpl.fire(EventImpl.java:68)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]

Re: CDI event propagation to ViewAccessScoped/ConversationScoped classes

Posted by Boris Brönner <bo...@gmail.com>.
Hi,


On Tue, Oct 8, 2013 at 4:15 PM, Thomas Andraschko <
andraschko.thomas@gmail.com> wrote:

> Hi,
>
> did you already try to set the reception on the @Observers annotation?
>

Wow, I didn't know that at all. That worked! Thanks a lot :)

Regards,
Boris


>
>
>
>
> 2013/10/8 Boris Brönner <bo...@gmail.com>
>
> > Hello,
> >
> > I have a database layer, that can be accessed by JSF and by REST. The
> > backing beans for JSF are ViewAccessScoped. The services for REST are
> > RequestScoped.
> >
> > When creating an entity, from both JSF or REST, an event should be raised
> > to notify all possible clients (JSF, but also other clients listening
> e.g.
> > JMS events). Now a problem occurs. When I create an entity using the REST
> > interface the event is raised as expected.
> >
> > However now WELD raises an ContextNotActiveException:
> >
> > org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active
> > contexts for scope type
> >
> >
> org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ViewAccessScoped
> >
> > I get the same problem when using the ConversationScoped annotation. This
> > problem occurs always when using the REST interface, i.e. whether or not
> I
> > have an JSF page open.
> >
> >
> > Below you find a more detailed stack trace starting from the point where
> > the event is fired.It seems like Weld thinks there is such a bean, but in
> > the end then can't get a context.
> >
> > What can I do here? Does the CODI implementation even work in this
> context?
> >
> > If you need more information about my setup, let me know :)
> >
> > Regards,
> > Boris
> >
> > Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303
> No
> > active contexts for scope type
> >
> >
> org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationScoped
> >     at
> >
> org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:598)
> > [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
> >     at
> >
> >
> org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:71)
> > [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
> >     at
> >
> >
> org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79)
> > [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
> >     at
> >
> >
> de.dfki.asr.compass.ejb.project.OpenScenarioBean$Proxy$_$$_WeldClientProxy.handleEntityCreated(OpenScenarioBean$Proxy$_$$_WeldClientProxy.java)
> > [classes:]
> >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > [rt.jar:1.7.0_11]
> >     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> > [rt.jar:1.7.0_11]
> >     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> > [rt.jar:1.7.0_11]
> >     at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_11]
> >     at
> >
> >
> org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:264)
> > [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
> >     at
> >
> >
> org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
> > [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
> >     at
> >
> >
> org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
> > [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
> >     at
> >
> >
> org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:260)
> > [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
> >     at
> >
> >
> org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:170)
> > [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
> >     at
> >
> >
> org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:51)
> > [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
> >     at
> >
> >
> org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:154)
> > [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
> >     at
> >
> >
> org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:241)
> > [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
> >     at
> >
> >
> org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:229)
> > [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
> >     at
> >
> org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:207)
> > [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
> >     at
> >
> >
> org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:569)
> > [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
> >     at
> >
> org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:564)
> > [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
> >     at org.jboss.weld.event.EventImpl.fire(EventImpl.java:68)
> > [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
> >
>



-- 
M.Sc. Boris Brönner
Researcher
Department Agents and Simulated Reality

German Research Center for Artificial Intelligence (DFKI)
Campus D 3.2, 66123 Saarbrücken

Re: CDI event propagation to ViewAccessScoped/ConversationScoped classes

Posted by Thomas Andraschko <an...@gmail.com>.
Hi,

did you already try to set the reception on the @Observers annotation?




2013/10/8 Boris Brönner <bo...@gmail.com>

> Hello,
>
> I have a database layer, that can be accessed by JSF and by REST. The
> backing beans for JSF are ViewAccessScoped. The services for REST are
> RequestScoped.
>
> When creating an entity, from both JSF or REST, an event should be raised
> to notify all possible clients (JSF, but also other clients listening e.g.
> JMS events). Now a problem occurs. When I create an entity using the REST
> interface the event is raised as expected.
>
> However now WELD raises an ContextNotActiveException:
>
> org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active
> contexts for scope type
>
> org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ViewAccessScoped
>
> I get the same problem when using the ConversationScoped annotation. This
> problem occurs always when using the REST interface, i.e. whether or not I
> have an JSF page open.
>
>
> Below you find a more detailed stack trace starting from the point where
> the event is fired.It seems like Weld thinks there is such a bean, but in
> the end then can't get a context.
>
> What can I do here? Does the CODI implementation even work in this context?
>
> If you need more information about my setup, let me know :)
>
> Regards,
> Boris
>
> Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No
> active contexts for scope type
>
> org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationScoped
>     at
> org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:598)
> [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
>     at
>
> org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:71)
> [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
>     at
>
> org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79)
> [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
>     at
>
> de.dfki.asr.compass.ejb.project.OpenScenarioBean$Proxy$_$$_WeldClientProxy.handleEntityCreated(OpenScenarioBean$Proxy$_$$_WeldClientProxy.java)
> [classes:]
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> [rt.jar:1.7.0_11]
>     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> [rt.jar:1.7.0_11]
>     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> [rt.jar:1.7.0_11]
>     at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_11]
>     at
>
> org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:264)
> [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
>     at
>
> org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
> [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
>     at
>
> org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
> [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
>     at
>
> org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:260)
> [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
>     at
>
> org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:170)
> [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
>     at
>
> org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:51)
> [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
>     at
>
> org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:154)
> [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
>     at
>
> org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:241)
> [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
>     at
>
> org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:229)
> [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
>     at
> org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:207)
> [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
>     at
>
> org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:569)
> [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
>     at
> org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:564)
> [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
>     at org.jboss.weld.event.EventImpl.fire(EventImpl.java:68)
> [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
>