title: java.lang.RuntimeException Cannot find FacesContext
body: <p>I don't know how to continue, but I always get the "java.lang.RuntimeException: Cannot find FacesContext" for my new JSF 1.2 web application. I'm sure it's just some configuration I can't find. </p>
  
  <p>The exception occurs with the first <code>f:</code> or <code>h:</code> tag. Already with the important <code>&lt;f:view&gt;</code> at the beginning.</p>
  
  <p>My <code>index.jsp</code></p>
  
  <pre><code>&lt;%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%&gt;
  &lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  
  &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
  &lt;f:view&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;MyWebsite&lt;/title&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;meta http-equiv="pragma" content="no-cache"&gt;
          &lt;meta http-equiv="cache-control" content="no-cache"&gt;
          &lt;meta http-equiv="expires" content="0"&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div&gt;MyContent&lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  &lt;/f:view&gt;
  </code></pre>
  
  <p>My <code>web.xml</code> looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;javax.faces.DEFAULT_SUFFIX&lt;/param-name&gt;
          &lt;param-value&gt;.jsp&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;session-config&gt;
          &lt;session-timeout&gt;720&lt;/session-timeout&gt;
      &lt;/session-config&gt;
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>And then I also have a <code>faces-config.xml</code> that should reference myBean I want to use afterward in the body of the page:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;
  &lt;faces-config version="1.2" 
                xmlns="http://java.sun.com/xml/ns/javaee" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"&gt;
      &lt;application&gt;
          &lt;view-handler&gt;com.sun.facelets.FaceletViewHandler&lt;/view-handler&gt;
      &lt;/application&gt;
  
      &lt;managed-bean&gt;
          &lt;managed-bean-name&gt;myClassName&lt;/managed-bean-name&gt;
          &lt;managed-bean-class&gt;
              com.company.className
          &lt;/managed-bean-class&gt;
          &lt;managed-bean-scope&gt;session&lt;/managed-bean-scope&gt;
      &lt;/managed-bean&gt;
  &lt;/faces-config&gt;
  </code></pre>
  
  <p>What am I missing here?</p>