Unfortunately the FacesContext, not being set on the current ThreadLocalVariable, is causing issues, as attempting to access the ExternalContext runs into the assertNotReleased() check. In this scenario, the user is trying to access the Session through the FacesContext in order to remove a session variable. Is it unsafe to set the FacesContext on the new Thread? If so, perhaps we could also allow injecting the ExternalContext or Session object?
WARNING: Failed to invokeinterface org.icefaces.bean.AllWindowsClosed on class com.acme.bean.web.UserInfoB
ean
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.icefaces.impl.application.WindowScopeManager.callAnnotatedMethod(WindowScopeManager.java:282)
at org.icefaces.impl.application.WindowScopeManager.access$1900(WindowScopeManager.java:42)
at org.icefaces.impl.application.WindowScopeManager$AllWindowsClosedNotifier.run(WindowScopeManager.java:655)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Caused by: java.lang.IllegalStateException
at com.sun.faces.context.FacesContextImpl.assertNotReleased(FacesContextImpl.java:654)
at com.sun.faces.context.FacesContextImpl.getExternalContext(FacesContextImpl.java:139)
at org.icefaces.impl.context.ICEfacesContext.getExternalContext(ICEfacesContext.java:25)
at com.acme.bean.web.UserInfoBean.allWindowsForSessionClosed(UserInfoBean.java:204)
... 9 more
Reverted injecting the FacesContext due to access restrictions on the ExternalContext. The workaround is to simply reference the necessary resource, such as the Session, etc. in a bean instance variable in a JSF thread, which will then be accessible to the AllWindowsClosed method handler outside of a JSF thread.
Wiki changes reverted.
Revision: 38586
Author: philip.breau
Date: October-11-13 3:00:12 PM
Message:
reverting Revision: 38294
Author: mircea.toma
Date: September-26-13 4:46:59 PM
as FacesContext must be set on the current ThreadLocalVariable for the ExternalContext to be used
Modified : /icefaces3/trunk/icefaces/core/src/main/java/org/icefaces/impl/application/WindowScopeManager.java