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

LVL 8
vsudipAsked:
Who is Participating?
 
HegemonConnect With a Mentor Commented:
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
 
HegemonConnect With a Mentor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.