Hi

I have found the bug. The problem was caused on a refactor, there was an
old code that skip state saving when view map is empty, but now since there
is a proxy for that implementing StateHolder, the map can be empty but it
holds the view scope key. Since with CDI the beans are stored internally,
the map keeps empty but the scope is not, and if the view scope key is lost
the bean is recreated every time. But the beans are still in session, and
with the session timeout bug the final result is @PreDestroy is not called.

Please try again with the latest code, it should work. And please lets us
know what happened, if it is working or not.

regards,

Leonardo Uribe



2013/10/17 Leonardo Uribe <lu4...@gmail.com>

> Hi
>
> I have committed a fix for the problem with the timeout. But I'm curious
> about this problem, because I tested this scope and specifically the
> @PreDestroy stuff. It should work. But maybe there is a bug somewhere....
>
> regards,
>
> Leonardo Uribe
>
>
> 2013/10/17 Howard W. Smith, Jr. <smithh032...@gmail.com>
>
>> responses inline below,
>>
>>
>>
>> On Thu, Oct 17, 2013 at 9:32 PM, Leonardo Uribe <lu4...@gmail.com> wrote:
>>
>> >
>> >     public void onSessionDestroyed()
>> >     {
>> >         // In CDI case, the best way to deal with this is use a method
>> >         // with @PreDestroy annotation on a session scope bean
>> >         // ( ViewScopeBeanHolder.destroyBeans() ). There is no need
>> >         // to do anything else in this location, but it is advised
>> >         // in CDI the beans are destroyed at the end of the request,
>> >         // not when invalidateSession() is called.
>> >         FacesContext facesContext = FacesContext.getCurrentInstance();
>> >         if (facesContext != null)
>> >         {
>> >
>> > I suppose what's going on there is in the context the session
>> invalidation
>> > is done, FacesContext is null and @PreDestroy is ignored.
>> >
>>
>> I can agree with that.
>>
>>
>> >
>> > To be clear two questions:
>> >
>> > 1. Is manual session expiration working ? I suppose yes.
>> >
>>
>> hmmm does manual session expiration == HttpSession.invalidate()?
>>
>> When user click Logout button, my app execute/triggers
>> HttpSession.invalidate(), and @PreDestroy (on CDI @ViewScoped bean) is not
>> executed.
>>
>>
>>
>> > 2. Is session invalidation by a timeout working ? I suppose no.
>> >
>>
>> correct, I just verified that in my app. see below.
>>
>> - navigated to page that reference CDI @ViewScoped bean, @PostConstruct
>> (below) executed
>>
>> Oct 17, 2013 9:45:18 PM jsf.orders.OrderDocumentBean init
>> INFO: jsf.orders.OrderDocumentBean@a9faef9
>>
>> changed web.xml, session timeout = 1 minute, so tomee ended session
>> via/after timeout, and @PreDestroy on CDI @SessionScoped (below) executed,
>>
>> Oct 17, 2013 9:45:53 PM jsf.users.pf_UsersController sessionTimeout
>> INFO: administrator session ended at 10/17/2013 09:45 PM
>>
>> but @PreDestroy on CDI @ViewScoped bean was not executed
>>
>>
>> I will try to provide an example to test.
>>
>
>

Reply via email to