Friday, June 1, 2012

java.lang.RuntimeException: FacesContext not found

Getting Following Exception While trying to test a HelloWorld JSF Application. I am hitting the
Test.jsp page, and getting this exception. 
 
org.apache.jasper.JasperException: java.lang.RuntimeException: FacesContext not found
 org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:502)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:430)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.lang.RuntimeException: FacesContext not found
 javax.faces.webapp.UIComponentClassicTagBase.getFacesContext(UIComponentClassicTagBase.java:321)
 javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:228)
 org.apache.jsp.Test_jsp._jspx_meth_f_005fview_005f0(Test_jsp.java:114)
 org.apache.jsp.Test_jsp._jspService(Test_jsp.java:88)
 org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 
 
 
 

1 comment:

  1. Its an issue with the URL being used. The web.xml has a path mapping for FacesServlet, every url should match that path pattern.
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>


    Also FacesServletis responsible for providing the FacesContext which is the actual error.

    Changed the URL from
    http://localhost:8080/testjsf/Test.jsp
    to
    http://localhost:8080/testjsf/faces/Test.jsp

    and it works just fine.

    ReplyDelete