Issue Details (XML | Word | Printable)

Key: JAVASERVERFACES-1717
Type: Bug Bug
Status: Closed Closed
Resolution: Won't Fix
Priority: Major Major
Assignee: rogerk
Reporter: pradeepk188
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
javaserverfaces

FacesContext.getCurrentInstance() returns null

Created: 28/Jun/10 07:03 AM   Updated: 29/Feb/12 09:36 PM   Resolved: 29/Feb/12 09:36 PM
Component/s: lifecycle
Affects Version/s: 1.2_04
Fix Version/s: None

Time Tracking:
Not Specified

Environment:

Operating System: All
Platform: All


Issuezilla Id: 1,717
Status Whiteboard:

size_medium importance_small

Tags:
Participants: Ed Burns, Manfred Riem, pradeepk188 and rogerk


 Description  « Hide

>>> java code
public class MyListener extends ConfigureListener{
public void contextInitialized(ServletContextEvent event) { super.contextInitialized(event); FacesContext context = FacesContext.getCurrentInstance(); }
}

>>> web.xml
...
<listener-class>
com.test.MyListener
</listener-class>
...

The value of context is null.

Although the default implementation is called through super.xxx() the context
is not ready yet. I tried to search for this problem but could not find any
info.



Ed Burns added a comment - 06/Jun/11 05:49 PM

Bulk assign all impl issues to Roger.


Manfred Riem added a comment - 29/Feb/12 09:36 PM

The FacesContext.getCurrentInstance is only guaranteed to be available within the scope of LifeCycle. Since you are calling the method outside of a LifeCycle there is no HTTP request and response that the FacesContext is associated with. As such that method is not available for usage.