title: Cannot lookup EJB3 from ServletContextListener in JBoss 4.2.3
body: <p>I have created an EJB timer with a local interface and I am not able to do JNDI lookup for it from a ServletContextListener.</p>
  
  <p>Here is part of the EJB code:</p>
  
  <pre><code>@Stateless
  @LocalBinding(jndiBinding = "TimedFileDeletion")
  public class TimedFileDeletionBean implements TimedFileDeletionBeanLocal {
  
   @Resource
      TimerService timerService;
   private String timerInfo = "FileDeletionTimer";
  
      public void startTimer() {
      ....
      }
  
      public boolean isItRunning() {
      ....
      }
  
      @Timeout
      public void timeout(Timer timer) {
      ....
      }
  }
  </code></pre>
  
  <p>Here is the local interface:</p>
  
  <pre><code>public interface TimedFileDeletionBeanLocal {
  
   public void startTimer();
  
   public boolean isItRunning();
  }
  </code></pre>
  
  <p>And here is the ServletContextListener:</p>
  
  <pre><code>public class StartupEventHandler implements ServletContextListener {
  
   TimedFileDeletionBeanLocal timedFileDeletionBeanLocal;
  
      public StartupEventHandler() {
       try {
     InitialContext ic = new InitialContext();
     timedFileDeletionBeanLocal = (TimedFileDeletionBeanLocal) ic.lookup("java:comp/env/ejb/TimedFileDeletion");
  
    } catch (NamingException e) {
     e.printStackTrace();
    }
      }
  
      public void contextInitialized(ServletContextEvent arg0) {
          if(!timedFileDeletionBeanLocal.isItRunning()) {
           timedFileDeletionBeanLocal.startTimer();
          }
      }
  
      public void contextDestroyed(ServletContextEvent arg0) {
  
      }
  }
  </code></pre>
  
  <p>For the lookup I also used the following Strings but none of the worked:
  - java:comp/env/TimedFileDeletion
  - java:comp/TimedFileDeletion
  - java:TimedFileDeletion
  - TimedFileDeletion</p>
  
  <p>In all cases I was getting a javax.naming.NameNotFoundException.</p>
  
  <p>Any advice would be appreciated.</p>