title: NullPointerException on @EJB annotated bean
body: <p>I have a problem when I try Override the getAsObject function</p>
  
  <pre><code>@FacesConverter("countryConverter")
  public class CountryConverter implements Converter {
  
  @EJB private CountryService countryService;
  
       @Override
          public Object getAsObject(FacesContext context, UIComponent arg1, String arg2){
  
           Country country = countryService.findByName(arg2);
           return country;
      }
  
  }
  </code></pre>
  
  <p>SO when I load my combobox in every post back</p>
  
  <pre><code>&lt;p:selectOneMenu value="#{registerController.selectedCountry}"
                  converter="countryConverter"&gt;
                  &lt;f:selectItems value="#{registerController.countries}" var="country"
                      itemLabel="#{country.name}" itemValue="#{country}" /&gt;
              &lt;/p:selectOneMenu&gt;
  </code></pre>
  
  <p>I got a nullPointer Exception in the findbyName line!, I check the arg2 paramater and it carrys a valid value, Also I test the service function and also it works fine... Outside the CountryConverter class.</p>
  
  <p><em>The error that I got is the follow, as I described in the getAsObject function line</em></p>
  
  <pre><code>SEVERE: java.lang.NullPointerException
      at com.garagesalelive.controllers.converter.CountryConverter.getAsObject(CountryConverter.java:29)
      at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:171)
      at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectOneValue(MenuRenderer.java:202)
      at com.sun.faces.renderkit.html_basic.MenuRenderer.getConvertedValue(MenuRenderer.java:319)
      at org.primefaces.component.selectonemenu.SelectOneMenuRenderer.getConvertedValue(SelectOneMenuRenderer.java:58)
      at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030)
      at javax.faces.component.UIInput.validate(UIInput.java:960)
      at javax.faces.component.UIInput.executeValidate(UIInput.java:1233)
      at javax.faces.component.UIInput.processValidators(UIInput.java:698)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
      at org.primefaces.component.dialog.Dialog.processValidators(Dialog.java:378)
      at javax.faces.component.UIForm.processValidators(UIForm.java:253)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
      at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1172)
      at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
      at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
      at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:722)
  
  SEVERE:     at com.garagesalelive.controllers.converter.CountryConverter.getAsObject(CountryConverter.java:29)
  SEVERE:     at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:171)
  SEVERE:     at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectOneValue(MenuRenderer.java:202)
  SEVERE:     at com.sun.faces.renderkit.html_basic.MenuRenderer.getConvertedValue(MenuRenderer.java:319)
  SEVERE:     at org.primefaces.component.selectonemenu.SelectOneMenuRenderer.getConvertedValue(SelectOneMenuRenderer.java:58)
  SEVERE:     at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030)
  SEVERE:     at javax.faces.component.UIInput.validate(UIInput.java:960)
  SEVERE:     at javax.faces.component.UIInput.executeValidate(UIInput.java:1233)
  SEVERE:     at javax.faces.component.UIInput.processValidators(UIInput.java:698)
  SEVERE:     at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
  SEVERE:     at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
  SEVERE:     at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
  SEVERE:     at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
  SEVERE:     at org.primefaces.component.dialog.Dialog.processValidators(Dialog.java:378)
  SEVERE:     at javax.faces.component.UIForm.processValidators(UIForm.java:253)
  SEVERE:     at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
  SEVERE:     at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
  SEVERE:     at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1172)
  SEVERE:     at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
  SEVERE:     at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
  SEVERE:     at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
  SEVERE:     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
  SEVERE:     at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
  SEVERE:     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
  SEVERE:     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
  SEVERE:     at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
  SEVERE:     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
  SEVERE:     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
  SEVERE:     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
  SEVERE:     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
  SEVERE:     at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
  SEVERE:     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
  SEVERE:     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
  SEVERE:     at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
  SEVERE:     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
  SEVERE:     at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
  SEVERE:     at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
  SEVERE:     at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
  SEVERE:     at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
  SEVERE:     at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
  SEVERE:     at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
  SEVERE:     at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
  SEVERE:     at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
  SEVERE:     at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
  SEVERE:     at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
  SEVERE:     at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
  SEVERE:     at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
  SEVERE:     at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
  SEVERE:     at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
  SEVERE:     at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
  SEVERE:     at java.lang.Thread.run(Thread.java:722)
  </code></pre>