Solved

FacesContext.getCurrentInstance() is null

Posted on 2010-11-19
5
1,134 Views
Last Modified: 2012-05-10
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
Comment
Question by:vsudip
  • 3
  • 2
5 Comments
 
LVL 10

Accepted Solution

by:
Hegemon earned 500 total points
ID: 34173103
Make sure the request is made using /faces in the URL
0
 
LVL 8

Author Comment

by:vsudip
ID: 34178186
I have weblogic portal application & placed JSF portlet in this. So how should I get the FacesContext ?
0
 
LVL 10

Expert Comment

by:Hegemon
ID: 34179308
See my previous question - is the request being made using "/faces" in the URL when you attempt to retrieve FacesContext ?
0
 
LVL 8

Author Comment

by:vsudip
ID: 34179393
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
 
LVL 10

Assisted Solution

by:Hegemon
Hegemon earned 500 total points
ID: 34179414
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now