title: EntityManager results in nullPointerException. Using Seam and JBOSS
body: <p>I am making a web-based application using SEAM and JBOSS. I am trying to make a converter for a drop-down box, but whenever I use entityManager within the converter class I get a NullPointerException. I have spent a couple days trying to figure this help and any help would be appreciated</p>
  
  <p>Here is some of my code. If anymore is needed, just let me know:</p>
  
  <p>Converter Class:</p>
  
  <pre><code>package edu.uwrf.iss.flowershop.entity;
  
  import javax.faces.application.FacesMessage;
  import javax.faces.component.UIComponent;
  import javax.faces.context.FacesContext;
  import javax.faces.convert.Converter;
  import javax.faces.convert.ConverterException;
  import javax.persistence.EntityManager;
  import javax.persistence.Query;
  import javax.servlet.ServletContext;
  import javax.swing.JOptionPane;
  
  import org.jboss.seam.annotations.In;
  import org.jboss.seam.annotations.Scope;
  
  public class EmpConverter implements Converter {
  
  @In
  private EntityManager entityManager;
  
  public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
      int num = Integer.parseInt(arg2);
      entityManager.refresh(getClass());
      Query query = entityManager.createQuery("SELECT e FROM FlowerStoreDelivery WHERE e.deliveryId LIKE :num")
                      .setParameter("num", num);
      JOptionPane.showMessageDialog(null, query.getResultList());
      FlowerStoreEmployee emp = entityManager.find(FlowerStoreEmployee.class, arg2);
      return emp;
  }
  
  public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) throws ConverterException {
  
  return Integer.toString(((FlowerStoreEmployee)arg2).getEmployeeId());
  }
  }
  </code></pre>
  
  <p>And this is where the converter is used:</p>
  
  <pre><code>    &lt;my:dropdown label="Employee ID" id="emp" value="#{deliveryPort.emp}"required="false"&gt;
                      &lt;f:converter converterId="EmpConverter" /&gt;
                      &lt;s:selectItems value="#{deliveryPort.empList}" var="emp" label="#{emp.employeeId} #{ emp.nameFirst}"/&gt; 
                  &lt;/my:dropdown&gt;
  </code></pre>