• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Faces Context null in serveResource Request

 
Mike Skit
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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
Posts: 18300
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic