title: NullPointerException: Passing value from one bean to another using CDI won't work
body: <p>I use this code in the JSF page</p>
  
  <pre><code>&lt;h:outputText value="#{writeBean.t}" /&gt;
  </code></pre>
  
  <p>(and I have a beans.xml in WEB-INF folder)</p>
  
  <p>this is the WriteBean where the latter StringBean is injected:</p>
  
  <pre><code>package huhu.main.managebean;
  
  import java.io.Serializable;
  import javax.enterprise.context.SessionScoped;
  import javax.enterprise.inject.Default;
  import javax.inject.Inject;
  import javax.inject.Named;
  
  
  @Default
  @Named
  @SessionScoped
  public class WriteBean implements Serializable {
     /**
   * 
   */
  private static final long serialVersionUID = 1L;
  
  String t;
  
  @Inject StringBean stringbean;
  
  
  public WriteBean() {
    setT(stringbean.getS());
  }
  
  public String getT() {
    return t;
  }
  
  public void setT(String t) {
    this.t = t;
  }
  }
  </code></pre>
  
  <p>and this is the StringBean where the string is set that I want to display on the JSF page:  </p>
  
  <pre><code>package huhu.main.managebean;
  
  import java.io.Serializable;
  import javax.enterprise.context.SessionScoped;
  import javax.enterprise.inject.Default;
  import javax.inject.Named;
  
  @Default
  @Named
  @SessionScoped
  public class StringBean implements Serializable {
  
     /**
  * 
  */
     private static final long serialVersionUID = 1L;
  
     String s = new String("WORKS!!");
  
     public StringBean(){
  
     }
  
     public String getS() {
       return s;
     }
  
     public void setS(String s) {
    this.s = s;
    }
  }
  </code></pre>
  
  <p>and this is the exception:  </p>
  
  <pre><code>    HTTP Status 500 -
  
  type Exception report
  
  message
  
  description The server encountered an internal error () that prevented it from fulfilling this request.
  
  exception
  
  javax.servlet.ServletException: java.lang.RuntimeException: java.lang.NullPointerException
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
      org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
  root cause
  
  com.google.common.collect.ComputationException: java.lang.RuntimeException: java.lang.NullPointerException
      com.google.common.collect.ComputingConcurrentHashMap$ComputingMapAdapter.get(ComputingConcurrentHashMap.java:397)
      org.jboss.weld.bean.proxy.ClientProxyProvider.getClientProxy(ClientProxyProvider.java:102)
      org.jboss.weld.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:115)
      org.jboss.weld.el.AbstractWeldELResolver.getValue(AbstractWeldELResolver.java:96)
      org.jboss.as.weld.webtier.jsf.ForwardingELResolver.getValue(ForwardingELResolver.java:46)
      javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)
      com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
      com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
      org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:72)
      org.apache.el.parser.AstValue.getValue(AstValue.java:147)
      org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
      org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
      com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
      javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
      javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
      javax.faces.component.UIOutput.getValue(UIOutput.java:169)
      com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
      com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
      com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
      javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
      com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
      com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
      javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
      com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
      com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
      org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
  root cause
  
  java.lang.RuntimeException: java.lang.NullPointerException
      org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInstantiation(SecureReflectionAccess.java:186)
      org.jboss.weld.util.reflection.SecureReflections.newInstance(SecureReflections.java:340)
      org.jboss.weld.bean.proxy.ProxyFactory.create(ProxyFactory.java:240)
      org.jboss.weld.bean.proxy.ClientProxyProvider.createClientProxy(ClientProxyProvider.java:87)
      org.jboss.weld.bean.proxy.ClientProxyProvider.access$000(ClientProxyProvider.java:43)
      org.jboss.weld.bean.proxy.ClientProxyProvider$1.apply(ClientProxyProvider.java:53)
      org.jboss.weld.bean.proxy.ClientProxyProvider$1.apply(ClientProxyProvider.java:46)
      com.google.common.collect.ComputingConcurrentHashMap$ComputingValueReference.compute(ComputingConcurrentHashMap.java:355)
      com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.compute(ComputingConcurrentHashMap.java:184)
      com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.getOrCompute(ComputingConcurrentHashMap.java:153)
      com.google.common.collect.ComputingConcurrentHashMap.getOrCompute(ComputingConcurrentHashMap.java:69)
      com.google.common.collect.ComputingConcurrentHashMap$ComputingMapAdapter.get(ComputingConcurrentHashMap.java:393)
      org.jboss.weld.bean.proxy.ClientProxyProvider.getClientProxy(ClientProxyProvider.java:102)
      org.jboss.weld.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:115)
      org.jboss.weld.el.AbstractWeldELResolver.getValue(AbstractWeldELResolver.java:96)
      org.jboss.as.weld.webtier.jsf.ForwardingELResolver.getValue(ForwardingELResolver.java:46)
      javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)
      com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
      com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
      org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:72)
      org.apache.el.parser.AstValue.getValue(AstValue.java:147)
      org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
      org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
      com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
      javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
      javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
      javax.faces.component.UIOutput.getValue(UIOutput.java:169)
      com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
      com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
      com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
      javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
      com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
      com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
      javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
      com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
      com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
      org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
  root cause
  
  java.lang.NullPointerException
      huhu.main.managebean.WriteBean.&lt;init&gt;(WriteBean.java:25)
      huhu.main.managebean.WriteBean$Proxy$_$$_WeldClientProxy.&lt;init&gt;(WriteBean$Proxy$_$$_WeldClientProxy.java)
      sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      java.lang.reflect.Constructor.newInstance(Unknown Source)
      java.lang.Class.newInstance0(Unknown Source)
      java.lang.Class.newInstance(Unknown Source)
      org.jboss.weld.util.reflection.SecureReflections$16.work(SecureReflections.java:343)
      org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
      org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInstantiation(SecureReflectionAccess.java:173)
      org.jboss.weld.util.reflection.SecureReflections.newInstance(SecureReflections.java:340)
      org.jboss.weld.bean.proxy.ProxyFactory.create(ProxyFactory.java:240)
      org.jboss.weld.bean.proxy.ClientProxyProvider.createClientProxy(ClientProxyProvider.java:87)
      org.jboss.weld.bean.proxy.ClientProxyProvider.access$000(ClientProxyProvider.java:43)
      org.jboss.weld.bean.proxy.ClientProxyProvider$1.apply(ClientProxyProvider.java:53)
      org.jboss.weld.bean.proxy.ClientProxyProvider$1.apply(ClientProxyProvider.java:46)
      com.google.common.collect.ComputingConcurrentHashMap$ComputingValueReference.compute(ComputingConcurrentHashMap.java:355)
      com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.compute(ComputingConcurrentHashMap.java:184)
      com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.getOrCompute(ComputingConcurrentHashMap.java:153)
      com.google.common.collect.ComputingConcurrentHashMap.getOrCompute(ComputingConcurrentHashMap.java:69)
      com.google.common.collect.ComputingConcurrentHashMap$ComputingMapAdapter.get(ComputingConcurrentHashMap.java:393)
      org.jboss.weld.bean.proxy.ClientProxyProvider.getClientProxy(ClientProxyProvider.java:102)
      org.jboss.weld.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:115)
      org.jboss.weld.el.AbstractWeldELResolver.getValue(AbstractWeldELResolver.java:96)
      org.jboss.as.weld.webtier.jsf.ForwardingELResolver.getValue(ForwardingELResolver.java:46)
      javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)
      com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
      com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
      org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:72)
      org.apache.el.parser.AstValue.getValue(AstValue.java:147)
      org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
      org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
      com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
      javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
      javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
      javax.faces.component.UIOutput.getValue(UIOutput.java:169)
      com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
      com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
      com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
      javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
      com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
      com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
      javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
      com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
      com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
      org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
  note The full stack trace of the root cause is available in the JBoss Web/7.0.13.Final logs.
  
  JBoss Web/7.0.13.Final
  </code></pre>