Calling a CDI session scoped producer method from an EJB stateless session bean
问题 I want to inject the current user using @Inject @Current User across all layers (i.e. web layer, EJB layer). In order to do this, I have the following CDI Producer method: @Named @SessionScoped public class UserController { @Resource SessionContext sessionContext; @EJB UserDao userDao; @Produces @Current public User getCurrentUser() { String username = sessionContext.getCallerPrincipal().getName(); User user = userDao.findByUsername(username); } } @Qualifier @Target({TYPE, METHOD, PARAMETER,