I do not understand why this is happening. Based on the code path, I should be within the same thread and session should be present, when this exception is raised.
Can somebody tell what I am missing here?
I have setup
<property name="hibernate.current_session_context_class">thread</property>
in hibernate.cfg.xml file
I have created the following code in Servlet filter
try{
factory.getCurrentSession().beginTransaction();
httpRequest.getRequestDispatcher("/public/index.html").forward(httpRequest,response);
}finally{
factory.getCurrentSession().getTransaction().commit();
}
In index.xhtml file, I have the following call:
do some stuff
index.xhtml is using template that uses ui include to load a menu.xhtml file. the menu file then inserts the menulist. servicesMenuItems call from menuItemsViewController eventually ends up in the following code
public Collection<Bulletin> getBulletin(User bean){
Session session=factory.getCurrentSession();
try{
session.refresh(bean);
if(bean.getObligations().size()>0){
do some stuff
}
As you can see session is present, when session.refresh(bean)
is not throwing exception but bean.getObligations()
is throwing,
failed to lazily initialize a collection of role: data.User.obligations, could not initialize proxy - no Session"
Any ideas why?