How to access BeanManager in a JEE application

There are different ways to get a reference to javax.enterprise.inject.spi.BeanManager in an JEE application:

  • @Inject private BeanManager beanManager;
  • private BeanManager bm = javax.enterprise.inject.spi.CDI.current().getBeanManager();

Especially the second one can be very handy if you hit a part that doesn’t support CDI already.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.