title: JSF page not retrieving variable from CDI bean
body: <p>I am trying to create a simple “hello world” test using JSF and CDI however the JSF page is not displaying a variable from the CDI bean. If the bean is changed to a managed bean then the variable is displayed.</p>
  
  <p>The test is using Apache MyFaces 2.1.5 and is running on WebSphere application server 8.5.</p>
  
  <p>No doubt there is a simple reason for the problem but I have been unable to establish why this works with a managed bean but not a CDI bean. Could someone please suggest where I'm going wrong?</p>
  
  <p>The content of the files in the test are as follows</p>
  
  <p><strong>test.xhtml</strong></p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"&gt;
  
  &lt;h:body&gt;
      &lt;h:outputText&gt;#{testBean.myval}&lt;/h:outputText&gt;
  &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>TestBean.java</strong></p>
  
  <pre><code>import javax.inject.Named;
  import javax.enterprise.context.RequestScoped;
  
  @Named
  @RequestScoped
  public class TestBean {
      private String myVal = "Hello World";
  
      public String getMyVal() {
          return myVal;
      }
  
      public void setMyVal(String myVal) {
          this.myVal = myVal;
      }
  }
  </code></pre>
  
  <p>I have also created an empty beans.xml file in WEB-INF.</p>