[ 
https://issues.apache.org/jira/browse/MYFACES-3940?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14209484#comment-14209484
 ] 

Sami Korhonen commented on MYFACES-3940:
----------------------------------------

I don't think CDI guarantees that referenced beans are valid. How would 
container determinate in which order beans should be removed, if they are e.g. 
crossreferencing each other or they are in same scope? If I'm not mistaken, 
@PreDestroy is used to release resource that current bean owns, not resources 
that are owned by another bean.

However @Singleton bean might just work, if it is referenced both by 
@ApplicationScoped bean and @Session bean. This is because singleton is not a 
proxy, but a direct reference. Just be sure to set reference from session bean 
as transient - otheriwse it will get serialized. Container should reinject 
bean, if it's working correctly

> FlowScopeBeanHolder calls ApplicationContextBean on PreDestroy
> --------------------------------------------------------------
>
>                 Key: MYFACES-3940
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3940
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-344
>    Affects Versions: 2.2.5
>         Environment: WebSphere 8.5.5.3
>            Reporter: Sami Korhonen
>
> Session scoped cdi bean FlowScopeBeanHolder relies on existance of 
> ApplicationContextBean. However, when application is shutdown there is no 
> guarantee that application scoped bean is destroyed after session scoped 
> bean. Because ApplicationContextBean no longer exists, application server to 
> throws an exception:
> [10.11.2014 10:06:50:511 EET] 00000072 ManagedBean   E ManagedBean error An 
> error occurred while executing [@PreDestroy.]
>                                  
> javax.enterprise.context.ContextNotActiveException: WebBeans context with 
> scope type annotation @ApplicationScoped does not exist within current thread
>       at 
> org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java:323)
>       at 
> org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:124)
>       at 
> org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.invoke(NormalScopedBeanInterceptorHandler.java:95)
>       at 
> org.apache.myfaces.cdi.view.ApplicationContextBean_$$_javassist_28.getServletContext(ApplicationContextBean_$$_javassist_28.java)
>       at 
> org.apache.myfaces.flow.cdi.FlowScopeBeanHolder.destroyBeansOnPreDestroy(FlowScopeBeanHolder.java:210)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to