Can't find FacesContext

From: Ralph Bunker <>
Date: Thu, 23 Oct 2008 17:48:55 -0500
If this is not the right place to post this, please let me know a better place.

I am preparing to teach JSF and want to be able to tell my students that FacesServlet is "just" a Servlet. To convince myself of that, I created a new Web Application project in NetBeans 6.1 and did not add the JSF libraries to it. I then downloaded the 1.2_09 Mojarra build from and copied all packages and config files to my NetBeans project. I created a small page with just a <f:view/> tag and ran that page.

I got it to compile and ConfigListener.contextInitialized and FacesServlet.init appear to run correctly on thread
Thread[httpWorkerThread-4848-0,10,Grizzly]. In particular, FacesContext.setInstance() is called before any call FacesContext.getInstance() so that getInstance never returns null.

However, when com.sun.faces.taglib.jsf_core.ViewTag.setJspId is called (it is running on thread Thread[httpSSLWorkerThread-8080-1,10,Grizzly]), it calls getFacesContext which calls FacesServlet.getInstance() before any call to FacesServlet.setInstance() on that thread and an "java.lang.RuntimeException: Cannot find FacesContext" exception is thrown because getInstance returns null.

My question is who is supposed to call FacesServlet.setInstance() on the ViewTag thread?

Any suggestions will be really appreciated.