myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leonardo Uribe (JIRA)" <>
Subject [jira] [Commented] (MYFACES-3940) FlowScopeBeanHolder calls ApplicationContextBean on PreDestroy
Date Tue, 25 Nov 2014 02:59:12 GMT


Leonardo Uribe commented on MYFACES-3940:

"... If I'm not mistaken, @PreDestroy is used to release resource that current bean owns,
not resources that are owned by another bean. ..."

The point is ApplicationContextBean is a wrapper used to hold servletContext reference, not
to release resources from another bean. This bean is initialized on application startup. Use
@Singleton will not work, because in a container like Tomee, we could have MyFaces shared
by multiple applications. 

The problem in that part of the code is we need to create a FacesContext instance to call
@PreDestroy over flow scope beans and you cannot do that without a servletContext instance.

Maybe the best we can do is write a warning on the log instead throw an exception. After all,
if the application is shutdown, the information stored in session is just destroyed.

> FlowScopeBeanHolder calls ApplicationContextBean on PreDestroy
> --------------------------------------------------------------
>                 Key: MYFACES-3940
>                 URL:
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-344
>    Affects Versions: 2.2.5
>         Environment: WebSphere
>            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
> 	at org.apache.webbeans.container.BeanManagerImpl.getContext(
> 	at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(
> 	at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.invoke(
> 	at org.apache.myfaces.cdi.view.ApplicationContextBean_$$_javassist_28.getServletContext(ApplicationContextBean_$$
> 	at org.apache.myfaces.flow.cdi.FlowScopeBeanHolder.destroyBeansOnPreDestroy(

This message was sent by Atlassian JIRA

View raw message