title: Unresolved <ejb-link>
body: <p>I'm developing in NetBeans 7, with EJB3.1 and Glassfish 3.1.
  I am trying to reference the Local Interface of a Session Bean in a JAR from a POJO in a WAR.
  When I deploy to Glassfish I receive:</p>
  
  <pre><code>SEVERE: Unresolved &lt;ejb-link&gt;: TaskTool-ejb#ContextFacade
  SEVERE: Exception while deploying the app [com.oracle.eas_TaskTool-ear_ear_1.0-SNAPSHOT]
  SEVERE: Error: Unresolved &lt;ejb-link&gt;: TaskTool-ejb#ContextFacade
  </code></pre>
  
  <p>I used the NetBeans helper to generate the code to reference the Session Bean's Local Interface and it generated the <code>&lt;ejb-local-ref&gt;</code> section in web.xml for me.</p>
  
  <pre><code>@Local
  public interface ContextFacadeLocal {
      void create(Context context);
      void edit(Context context);
      void remove(Context context);
      Context find(Object id);
      List&lt;Context&gt; findAll();
      List&lt;Context&gt; findRange(int[] range);
      int count();
      List&lt;Context&gt; findRootContexts();
  }
  
  @Stateless
  public class ContextFacade extends AbstractFacade&lt;Context&gt; implements ContextFacadeLocal {
      @PersistenceContext(unitName = "TaskToolPU")
      private EntityManager em;
  
      protected EntityManager getEntityManager() {
          return em;
      }
  
      public ContextFacade() {
          super(Context.class);
      }
  
      @Override
      public List&lt;Context&gt; findRootContexts() {
          CriteriaBuilder builder = em.getCriteriaBuilder();
          CriteriaQuery&lt;Context&gt; query = builder.createQuery(Context.class);
          Root&lt;Context&gt; c = query.from(Context.class);
          query.select(c).where(builder.isNull(c.get("parent")));
          query.orderBy(builder.asc(c.get("id")));
  
          TypedQuery&lt;Context&gt; q = em.createQuery(query);
          return q.getResultList();
      }
  }
  
  @FacesConverter(value = "contextConverter")
  public class contextConverter implements Converter {
  
      ContextFacadeLocal contextFacade = lookupContextFacadeLocal();
  
      @Override
      public Object getAsObject(FacesContext fc, UIComponent uic, String string) {
          return contextFacade.find(string);
      }
  
      @Override
      public String getAsString(FacesContext fc, UIComponent uic, Object o) {ntityManager() {
          return em;
      }
  
      public ContextFacade() {
          super(Context.class);
      }
  
      @Override
      public List&lt;Context&gt; findRootContexts() {
          CriteriaBuilder builder = em.getCriteriaBuilder();
          CriteriaQuery&lt;Context&gt; query = builder.createQuery(Context.class);
          Root&lt;Context&gt; c = query.from(Context.class);
          query.select(c).where(builder.isNull(c.get("parent")));
          query.orderBy(builder.asc(c.get("id")));
  
          TypedQuery&lt;Context&gt; q = em.createQuery(query);
          return q.getResultList();
      }
  }
  
  @FacesConverter(value = "contextConverter")
  public class contextConverter implements Converter {
  
      ContextFacadeLocal contextFacade = lookupContextFacadeLocal();
  
      @Override
      public Object getAsObject(FacesContext fc, UIComponent uic, String string) {
          return contextFacade.find(string);
      }
  
      @Override
      public String getAsString(FacesContext fc, UIComponent uic, Object o) {
          return ((Context) o).getId().toString();
      }
  
      private ContextFacadeLocal lookupContextFacadeLocal() {
          try {
              javax.naming.Context c = new InitialContext();
              //return (ContextFacadeLocal) c.lookup("java:global/com.oracle.eas_TaskTool-ear_ear_1.0-SNAPSHOT/com.oracle.eas_TaskTool-ejb_ejb_1.0-SNAPSHOT/ContextFacade!com.oracle.eas.ejbs.ContextFacadeLocal");
              return (ContextFacadeLocal) c.lookup("java:comp/env/TaskTool-ejb#ContextFacade");
  
          } catch (NamingException ne) {
              Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
              throw new RuntimeException(ne);
          }
      }
  }
  
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;/param-name&gt;
          &lt;param-value&gt;Development&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/faces/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;session-config&gt;
          &lt;session-timeout&gt;
              30
          &lt;/session-timeout&gt;
      &lt;/session-config&gt;
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;faces/index.xhtml&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
      &lt;ejb-local-ref&gt;
          &lt;ejb-ref-name&gt;ContextFacade&lt;/ejb-ref-name&gt;
          &lt;ejb-ref-type&gt;Session&lt;/ejb-ref-type&gt;
          &lt;local&gt;com.oracle.eas.ejbs.ContextFacadeLocal&lt;/local&gt;
          &lt;ejb-link&gt;TaskTool-ejb#ContextFacade&lt;/ejb-link&gt;
      &lt;/ejb-local-ref&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>For clarity:</p>
  
  <p>I don't have an ejb-jar.xml at all. </p>
  
  <p>Using either <code>&lt;ejb-link&gt;TaskTool-ejb/ContextFacade&lt;/ejb-link&gt;</code> or <code>&lt;ejb-link&gt;com.oracle.eas_TaskTool-ejb_ejb_1.0-SNAPSHOT/ContextFacade&lt;/ejb-link&gt;</code> works. </p>
  
  <p>Please see bkail answers below for explanation.  Many thanks!</p>