2 Replies Latest reply on Jan 13, 2008 4:15 AM by Dave Chen

    java.lang.RuntimeException: Cannot find FacesContext

    ruchi thakur Newbie

      I am new to EJB 3.0 and jboss sever. Am really stuck. Would appreciate any help.
      I am using JSF + ejb3.0 + jboss 4.2
      My jsf was running fine on jboss 4.0.5 GA, but in jboss 4.2 i get the below Exception, when i try to access jsf from ie
      Cannot find FacesContext
      java.lang.RuntimeException: Cannot find FacesContext
      at javax.faces.webapp.UIComponentClassicTagBase.getFacesContext(UIComponentClassicTagBase.java:1797)
      at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1614)
      at org.apache.jsp.welcome_jsp._jspx_meth_f_005fview_005f0(welcome_jsp.java:106)
      at org.apache.jsp.welcome_jsp._jspService(welcome_jsp.java:83)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

      ---------------------------------------
      Below is the listener in my web.xml
      <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>

      -------------------------------------------
      Also i have placed myfaces library jars in web-inf/lib folder of my application

      Please suggest

      Regards,
      Ruchika

        • 1. Re: java.lang.RuntimeException: Cannot find FacesContext
          Wolfgang Knauf Master

          Hi Ruchika,

          I encountered the same problem with Suns RI.
          The problem is: the faces context is initialized the first time you make a call to the faces servlet. This does not happen if yo call the page directly.

          Solution 1:
          browse to "welcome.faces" (or "welcome.jsf", depending on the faces url pattern) instead of "welcome.jsp".

          Solution 2:
          build a plain JSP index page which links to your faces page. This index page should contain this link:

          <a href="welcome.faces">Start page</a>


          Solution 3:
          the index page contains a redirect to your jsf page:
          <%@ page session="false" language="java" contentType="text/html; charset=ISO-8859-1"%>
          <% response.sendRedirect("geometricmodel.faces"); %>


          Hope this helps

          Wolfgang

          • 2. Re: java.lang.RuntimeException: Cannot find FacesContext
            Dave Chen Master

            JBoss 4.2.2 myfaces,
            I got the same problem with explicit page index.jsf with correct servlet mapping.