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

Cannot find FacesContext

RalphMichelsen Michelsen

Joined: Apr 17, 2006
Posts: 4
Hello everyone

I am rather new to jsf and I have run into a big black hole ;-)

After I have deployed my app. and I call my bankUI.jsp through my jsf mapping I get the following error:

javax.servlet.jsp.JspException: Cannot find FacesContext
... rest of stacktrace ....

This is my setup:

App.server: jboss-4.0.4RC1

<!-- Faces Servlet -->
<servlet-name>Faces Servlet</servlet-name>
<!-- Faces Servlet Mapping -->
<servlet-name>Faces Servlet</servlet-name>

web-client.war (struture)



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<head> </head>

<%@ taglib uri="" prefix="f" %>
<%@ taglib uri="" prefix="h" %>


<h:form id="form">
<h utputText id="overskrift" value="Ralph�s Bank" style="font-family:Arial, sans-serif; font-size=24;color=green"/>
<h utputLabel for="cprsoeg">
<h utputText id="cprsoegtext" value="Soeg cprnr."/>
</h utputLabel>
<h:inputText id="cprsoeg" value="#{bankUIBean.cprnr}" required="true">
<f:validateLongRange minimum="10" maximum="10"/>
<h:message id="errors" for="cprsoeg" style="color:red" />



There are no errors on deployment, and my app. runs find. But when i try to acces my bankUI.jsp i get the error above.
And I do go through the correct jsf mapping http://localhost:8080/project_1app/bankUI.jsf

Now if I remove all my jsf related tags from my jsp file (bankUI.jsp) the page is displayed correct. So the error occurs when i hit the first jsf tag on my jsp page.

I also run ejb3.0 on my jboss app server. I don't know if that is usefull information.


Ralph Michelsen
A Saari

Joined: Mar 31, 2006
Posts: 26
mine looks like:

<servlet-name>Faces Servlet</servlet-name>
<servlet-name>Faces Servlet</servlet-name>

RalphMichelsen Michelsen

Joined: Apr 17, 2006
Posts: 4
hey Amy

Thanks for your reply.

How ever I have already tried a different mapping in my web.xml, but this did not solve my problem

I believe that my jboss app. server for some reason does not start up an instance of the facesservlet. I have not found the solution yet, but I am stilling searching

regards Ralph
Mohammad Ibrahim
Ranch Hand

Joined: Nov 28, 2004
Posts: 51
have you tried to deploy your application on some other server. I deploy my JSF applications in Tomcat 5.0 and it works absolutely fine.
My web.xml reads as follows (my sample app had Struts capabilities):

RalphMichelsen Michelsen

Joined: Apr 17, 2006
Posts: 4
First of all, thank you for your respons.

I have solved my problem with a little help from a guy at Sun jsf Forums.

He wrote the following very helpfull lines
As for your other problems, make sure you don't have multiple versions of the JSF libs in your app. If you're running on JBoss, you'll likely have all the JBoss libs in $JBOSS_HOME/server/default/deploy/jbossweb-tomcat55.sar/jsf-libs

If you package another set of JSF libs in your WEB-INF/lib directory this can cause the kind of problem you're seeing. So, in short, make sure that the above directory contains the MyFaces JSF impl and ensure that you're not packaging another set of JSF jars in your ear.

This was exactly my problem. I had a different set of jsf jars in my web-inf/lib than in the JBOSS installation. When I corrected this, there were no problems anymore.

Thanks all.

Paul Suchko

Joined: Jul 13, 2009
Posts: 1
This also happens if you try running the underlying JSP file without using the correct extension which causes the Faces servlet to be invoked first (e.g. xxx.jsp instead of xxx.iface)
sancho sebastine

Joined: Aug 24, 2009
Posts: 1
Thanks for the tips. It helped. I had the same problem.

I found that it was because my file was named as sample.jsp and not sample.jspx. When i renamed the file as sample.jspx everything was fixed. I created the file in eclipse and it had automatically named with .jsp extension. If you are working with eclipse you might want to look at this.

Hope it helps someone
I agree. Here's the link:
subject: Cannot find FacesContext
Similar Threads
ServeletException, PropertyNnotFoundException
tomcat 5
Problems with running JSF in Eclipse 3.1
Problems in JSF running with MyEclipse
Error: Target Unreachable, identifier 'StoreNameBean' resolved to null