As an alternative to #
There should be a standard way to obtain a BeanManager instance regardless of environment. I propose a BeanManagerFactory that would implement the following resolution:
1) if in a JEE environment, use the JNDI resolution already proposed on spec
2) if in a non-JEE servlet container, use the servlet context attribute as proposed in #
3) else, fallback on a "singleton" BeanManager
For extensability, one could override the resolution mechanism by providing his own BeanManagerResolver.