CDI session bean initialization

▼魔方 西西 提交于 2019-12-11 15:49:49

问题


I have two beans:

@Named
@SessionScoped
public class Session implements Serializable {
    private String temp;
    +getter, setter

}

@Named
@RequestScoped
public class Test {
    @Inject
    private Session s;

    @PostConstruct
    public void init() {
        this.sth = s.getTemp(); //here is exception
    }
}

When I try to fetch in init same value from session I get NullPointerException. What am I doing wrong? Server is JBoss eap 6.0, JSF v2.1. Thanks in advance

Edit: I investigated that problem appears only when I have more than 11 items in primefaces submenu component. If I have less than 11 items every thinks work OK. I am using PrimeFaces v 3.5. Edit 2: On session bean only constructor is invoked. I have method annotated with PostConstruct but it is not called. I always get NullPointerException after invoking any method on session from Test bean.

来源:https://stackoverflow.com/questions/15411009/cdi-session-bean-initialization

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!