You're basically manually spawning a thread. The FacesContext
is only available in the thread serving the HTTP request which matches the URL pattern of the FacesServlet
, not in other threads. The FacesContext#getCurrentInstance()
would return null
in all other threads.
Think once again, how would you ever send a message to the HTTP response without that the client has sent a HTTP request? By default, you can't send anything to the client without that it has requested for it.
Look for poll/push techniques. This concrete problem is completely unrelated to the class hierarchy/scope. In the future, it'd be more helpful for you and us if you've identified what exactly is null
. You seem to not have done that at all.