title: Java EE Cannot resolve reference Local ejb-ref
body: <p>I'm getting the following error:</p>
  
  <pre><code>Severe:   Exception while deploying the app [snel-transport-web] : Cannot resolve reference Local ejb-ref name=UserFacade,Local 3.x interface =null,ejb-link=null,lookup=,mappedName=,jndi-name=,refType=Session
  </code></pre>
  
  <p>I had googled the error and I had arrived on the following questions on Stack Overflow:</p>
  
  <p><a href="https://stackoverflow.com/questions/16167712/ejb-injection-failure-on-deploy">EJB Injection failure on deploy</a></p>
  
  <p><a href="https://stackoverflow.com/questions/12823527/getting-cannot-resolve-reference-local-ejb-ref-not-implementing-parent-interface">Getting Cannot resolve reference Local ejb-ref not implementing parent interface</a></p>
  
  <p>I assume it has something to do with my annotations <code>@remote</code> and <code>@LocalBean</code>.</p>
  
  <p>Here is the code that I currently have:</p>
  
  <p>AbstractFacade.java:</p>
  
  <pre><code>@Remote
  public abstract class AbstractFacade&lt;T&gt; {
  
      private Class&lt;T&gt; entityClass;
  
      public AbstractFacade(Class&lt;T&gt; entityClass) {
          this.entityClass = entityClass;
      }
  
      protected abstract EntityManager getEntityManager();
  
      public void create(T entity) {
          getEntityManager().persist(entity);
      }
  
      public void edit(T entity) {
          getEntityManager().merge(entity);
      }
  
      public void remove(T entity) {
          getEntityManager().remove(getEntityManager().merge(entity));
      }
  
      public T find(Object id) {
          return getEntityManager().find(entityClass, id);
      }
  
      public List&lt;T&gt; findAll() {
          javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
          cq.select(cq.from(entityClass));
          return getEntityManager().createQuery(cq).getResultList();
      }
  
      public List&lt;T&gt; findRange(int[] range) {
          javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
          cq.select(cq.from(entityClass));
          javax.persistence.Query q = getEntityManager().createQuery(cq);
          q.setMaxResults(range[1] - range[0] + 1);
          q.setFirstResult(range[0]);
          return q.getResultList();
      }
  
      public int count() {
          javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
          javax.persistence.criteria.Root&lt;T&gt; rt = cq.from(entityClass);
          cq.select(getEntityManager().getCriteriaBuilder().count(rt));
          javax.persistence.Query q = getEntityManager().createQuery(cq);
          return ((Long) q.getSingleResult()).intValue();
      }  
  }
  </code></pre>
  
  <p>UserFacade.java:</p>
  
  <pre><code>@Stateless
  @LocalBean
  public class UserFacade extends AbstractFacade&lt;User&gt; {
  
      @PersistenceContext(unitName = "com.mycompany_snel-transport-ejb_ejb_1.0-SNAPSHOTPU")
      private EntityManager em;
  
      @Override
      protected EntityManager getEntityManager() {
          return em;
      }
  
      public UserFacade() {
          super(User.class);
      }   
  }
  </code></pre>
  
  <p>AuthCtrl.java:</p>
  
  <pre><code>@Path("/auth")
  @ApplicationPath("/api")
  public class AuthCtrl extends Application {
  
      com.mycompany.UserFacade userFacade = lookupUserFacadeBean();
  
      /**
       * 
       * @return 
       */
      @GET
      @Path("/user")
      public String getHelloMsg() {
          return "test";
      }
  
      /**
       * 
       * @param message
       * @return
       */
      @POST
      @Path("/register")
      public String register(String message) {
          // Register user
  //        userFacade.create(entity);
  
          return "done registering";
      }
  
      private com.mycompany.UserFacade lookupUserFacadeBean() {
          try {
              Context c = new InitialContext();
              return (com.mycompany.UserFacade) c.lookup("java:global/com.mycompany_snel-transport-ear_ear_1.0-SNAPSHOT/com.mycompany_snel-transport-ejb_ejb_1.0-SNAPSHOT/UserFacade!com.mycompany.UserFacade");
          } catch (NamingException ne) {
              Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
              throw new RuntimeException(ne);
          }
      }
  }
  </code></pre>