title: WELD-001300 when trying to lookup BeanManager by JNDI
body: <p>I configured Jetty 9.2.5 + Weld 2.2.7 (currently the latest versions) as described by the <a href="https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html" rel="nofollow">Weld documentation</a>.</p>
  
  <p>Everything works fine, except the lookup of the BeanManager by JNDI. Lookup of other JNDI entries just work as expected. I got the error (note this is not a <code>javax.naming.NameNotFoundException</code>)</p>
  
  <pre><code>javax.naming.NamingException: WELD-001300: Unable to locate BeanManager
  </code></pre>
  
  <p>The code I use:</p>
  
  <pre><code>BeanManager beanManager = null;
  try {
      final Context ctx = new InitialContext();
      try {
          // JNDI name defined by spec
          beanManager = (BeanManager) ctx.lookup("java:comp/BeanManager");
      } catch (NameNotFoundException nf1) {
          try {
              // JNDI name used by Tomcat and Jetty
              beanManager = (BeanManager) ctx.lookup("java:comp/env/BeanManager");
          } catch (NameNotFoundException nf2) {
          }
      }
  } catch (NamingException ex) {
      System.err.println(ex);
  }
  return beanManager;
  </code></pre>
  
  <p>Complete test code can be found at <a href="https://github.com/rmuller/java8-examples/tree/master/jetty-maven-cdi" rel="nofollow">https://github.com/rmuller/java8-examples/tree/master/jetty-maven-cdi</a></p>