title: @EJB is null in @ManagedBean
body: <p>I am very new to the web application development. I am trying to implement an EJB call to my ManagedBean method from JSF command button. </p>
  
  <p>here is sample code: 
  JSF : </p>
  
  <pre><code>&lt;h:commandButton value="CommandButton" action="#{someBean.someBeanMethod}" /&gt;
  </code></pre>
  
  <p>ManagedBean : </p>
  
  <pre><code>  @ManagedBean
      @ViewScoped
      public class SomeBeanClient implements Serializable {
  
          private static final long serialVersionUID = 1L;
          @EJB
          private Service service ;
  
          public String someBeamMethod() throws NamingException  {
               final Future&lt;String&gt; red = service.someAsyncMethod();
               service.someSyncMethod();
              return "DummyValue";
          }
      }
  </code></pre>
  
  <p>EJB Class  : </p>
  
  <pre><code> @Stateless
      public class Service {
  
          @Asynchronous
          public Future&lt;String&gt; someAsyncMethod(){
               try {
                   System.out.println("Gd nyt");
                   Thread.sleep(10000);
                   System.out.println("Gd mrning");
                  } catch (InterruptedException e) {
                      Thread.currentThread().interrupt();
                  }
               return new AsyncResult&lt;String&gt;("success");
          }
          public void someSyncMethod(){
                   System.out.println("Gd Day");
          }
      }
  </code></pre>
  
  <p>Expecting S.O.P in following order :
  Gd nyt
  Gd Day
  Gd mrning</p>
  
  <p>Actual Result:</p>
  
  <pre><code>servlet       E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0014E: Uncaught service() exception root cause Faces Servlet: javax.servlet.ServletException: Error calling action method of component with id paneForm:content:PushToGIT:_idJsp72:_idJsp165
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:154)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1225)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:775)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:457)
      at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97)
      at ilog.rules.teamserver.web.security.SecurityCheckPointFilter.doFilter(SecurityCheckPointFilter.java:112)
      at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
      at ilog.rules.teamserver.web.servlets.filter.IlrAccessFilter.doFilter(IlrAccessFilter.java:199)
      at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
  
  Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{someBean.someBeanMethod}
      at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:156)
      at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
      ... 49 more
  Caused by: java.lang.NullPointerException
      at com.tiaa.brms.ejb.SomeBeanClient.someBeanMethod(SomeBeanClient.java:33)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:76)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:607)
      at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
      ... 50 more
  </code></pre>