| Author |
javax.servlet. ServletException: Cannot find FacesContext
|
madhup narain
Ranch Hand
Joined: Dec 14, 2004
Posts: 148
|
|
hi i am novice user trying my hands on JSF, i have followed the J2ee tutorial for JSF (guessNumber example) I am using the Sun Application Server I am getting the following error after successfully deploying the JSF Can someone help me out Regards exception javax.servlet.ServletException: Cannot find FacesContext org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:830) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:763) org.apache.jsp.greeting_jsp._jspService(greeting_jsp.java:116) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:105) javax.servlet.http.HttpServlet.service(HttpServlet.java:860) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:336) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:251) javax.servlet.http.HttpServlet.service(HttpServlet.java:860) sun.reflect.GeneratedMethodAccessor110.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:585) org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249) java.security.AccessController.doPrivileged(Native Method) javax.security.auth.Subject.doAsPrivileged(Subject.java:517) org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282) org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165) root cause javax.servlet.jsp.JspException: Cannot find FacesContext javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:405) com.sun.faces.taglib.jsf_core.ViewTag.doStartTag(ViewTag.java:105) org.apache.jsp.greeting_jsp._jspx_meth_f_view_0(greeting_jsp.java:131) org.apache.jsp.greeting_jsp._jspService(greeting_jsp.java:107) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:105) javax.servlet.http.HttpServlet.service(HttpServlet.java:860) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:336) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:251) javax.servlet.http.HttpServlet.service(HttpServlet.java:860) sun.reflect.GeneratedMethodAccessor110.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:585) org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249) java.security.AccessController.doPrivileged(Native Method) javax.security.auth.Subject.doAsPrivileged(Subject.java:517) org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282) org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
|
Money for nothing and Java for Free
SCJP, SCWCD
|
 |
James Ellis
Ranch Hand
Joined: Oct 14, 2004
Posts: 205
|
|
Check the following things: 1) You have the jar files required for JSF in the right place. 2) You have the correct entries in web.xml (mine looks like this) 3) You have the following entries at the top of your page (implementation specific)
|
 |
James Ellis
Ranch Hand
Joined: Oct 14, 2004
Posts: 205
|
|
I also forgot, you can get this error if you try to go directly to the JSP page without routing your request through the faces servlet. This would happen if you went to pagename.jsp instead of pagename.jsf if you had the following entry in web.xml
|
 |
madhup narain
Ranch Hand
Joined: Dec 14, 2004
Posts: 148
|
|
Thanks for the reply. My web.xml file looks like this. ?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>guessNumber</display-name> <servlet> <display-name>FacesServlet</display-name> <servlet-name>FacesServlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>FacesServlet</servlet-name> <url-pattern>/guess/*</url-pattern> </servlet-mapping> </web-app> and yes i have the tag entries at the top of my page <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> i guess so theres something amisss from the web.xml file
|
 |
Sergey Smirnov
Ranch Hand
Joined: May 29, 2003
Posts: 167
|
|
What URL you use when you call the page? It should be a prefix /guess/ between the host name and the path to the page. See also: http://jsffaq.com/Wiki.jsp?page=WhatDoesCannotFindFacesContextExceptionMeans
|
 |
 |
|
|
subject: javax.servlet. ServletException: Cannot find FacesContext
|
|
|