code: public static BeanManager getBeanManager() {
          try {
              InitialContext initialContext = new InitialContext();
              return (BeanManager) initialContext.lookup("java:comp/BeanManager");
          } catch (NamingException e) {
              log.log(Level.SEVERE, "Couldn't get BeanManager through JNDI", e);
              return null;
          }
      }
docs: Retrieves the #{@link BeanManager} instance via JNDI.
  
  @return The found bean manager instance if found, otherwise null