• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1199
  • Last Modified:

FacesContext.getCurrentInstance() is null

I have developed a JSF portlet and in ManagedBean I am trying to get FacesContext for exception handling. But I am getting FacesContext.getCurrentInstance() is null. I am attaching web.xml portion below. ANy help would be appreciated.
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>

Open in new window

0
vsudip
Asked:
vsudip
  • 3
  • 2
2 Solutions
 
HegemonCommented:
Make sure the request is made using /faces in the URL
0
 
vsudipAuthor Commented:
I have weblogic portal application & placed JSF portlet in this. So how should I get the FacesContext ?
0
 
HegemonCommented:
See my previous question - is the request being made using "/faces" in the URL when you attempt to retrieve FacesContext ?
0
 
vsudipAuthor Commented:
No..... I do not think so..... I am executing my portal file on server (for ex:  htttp://......../xyz.portal). Is there any other way to fetch the portlet detail so that FacesContext won't be null or any change in web.xml required ?
0
 
HegemonCommented:
FacesContext will only be active if the request it received is a Faces Request. For a request to be a Faces Request, it should be passed through FacesServlet - in your configuration, it should start with "/faces" but you can also add other mapping, i.e. *.xhtml
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now