File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Faces Context null in serveResource Request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Faces Context null in serveResource Request" Watch "Faces Context null in serveResource Request" New topic

Faces Context null in serveResource Request

Mike Skit

Joined: Feb 09, 2008
Posts: 23
I am using jsf based jsr 286 portlets.
When invoking a ajax call to serveResource, i attempt to retrieve the Managed Bean using the FacesContext and get the following exception

"Config is null, please ensure that your init(config) method calls super.init(config) "

Can somebody point me to the solution to this ?

Thanks in advance.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

You're short on details there, but the most common reason for a null Faces Context is when people attempt to reference it in JSPs and servlets.

The FacesContext does not exist as a long-term object. It is created and destroyed by the FacesServlet to handle the current http request/response process and ONLY the current http request/response process. The rest of the time it simply doesn't exist. And if you're making a non-JSF request, the FacesServlet doesn't process it, so it hasn't constructed the FacesContext.

However, you don't need the FacesContext to access managed beans. If a Managed Bean is in session or application scope, you can access it using the HttpSession.getAttribute method or the application-scope equivalent just like non-JSF attributes. There's nothing JSF-specific about how these objects are stored. Request scope objects would be the same way, except that request scope objects have such a short lifespan that they would have been destroyed before the non-JSF request was made.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Faces Context null in serveResource Request
jQuery in Action, 3rd edition