NullPointerException while trying to access @Inject bean in constructor

后端 未结 2 2083
别跟我提以往
别跟我提以往 2020-11-29 06:59

I\'ve a session scoped bean:

@Named
@SessionScoped
public class SessionBean implements Serializable {

    private String someProperty;

    public String ge         


        
2条回答
  •  半阙折子戏
    2020-11-29 07:37

    BalusC's reply is correct, but is does reflect the assignment phase of a object creation, that did not run at this time. But anyway the CDI bean should be accessible if you grep it programatically via:

    javax.enterprise.inject.spi.CDI.current().select(SessionBean.class).get()
    

提交回复
热议问题